Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-09-29 08:11:57
Exec Total Coverage
Lines: 8366 12158 68.8%
Functions: 92 126 73.0%
Branches: 5506 10317 53.4%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/util.h"
3 #include "base/zapp.h"
4 #include "base/qrs.h"
5 #include "base/cpool.h"
6 #include "base/autocombo.h"
7 #include "base/packfile.h"
8 #include "base/dmap.h"
9 #include "base/combo.h"
10 #include "base/msgstr.h"
11 #include <filesystem>
12 #include <stdio.h>
13 #include <cstring>
14 #include <string>
15 #include <map>
16 #include <vector>
17 #include <assert.h>
18 #include <fmt/format.h>
19
20
21 #include "metadata/sigs/devsig.h.sig"
22 #include "metadata/sigs/compilersig.h.sig"
23 #include "metadata/versionsig.h"
24 #include "base/zc_alleg.h"
25 #include "base/zdefs.h"
26 #include "base/colors.h"
27 #include "tiles.h"
28 #include "base/zsys.h"
29 #include "qst.h"
30 #include "defdata.h"
31 #include "subscr.h"
32 #include "font.h"
33 #include "zc/replay.h"
34 #include "zc/zc_custom.h"
35 #include "sfx.h"
36 #include "md5.h"
37 #include "zinfo.h"
38 #include "zc/ffscript.h"
39 #include "particles.h"
40 #include "dialog/alert.h"
41 #include "base/misctypes.h"
42
43 //FFScript FFCore;
44 extern FFScript FFCore;
45 extern ZModule zcm;
46 extern zcmodule moduledata;
47 extern uint8_t __isZQuest;
48 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
49 extern particle_list particles;
50 extern void setZScriptVersion(int32_t s_version);
51 //FFSCript FFEngine;
52
53 int32_t temp_ffscript_version = 0;
54 static bool read_ext_zinfo = false, read_zinfo = false;
55 static bool loadquest_report = false;
56 static char const* loading_qst_name = NULL;
57 static byte loading_qst_num = 0;
58
59 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
60 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
61
62 #ifdef _MSC_VER
63 #define strncasecmp _strnicmp
64 #endif
65
66 #ifndef _AL_MALLOC
67 #define _AL_MALLOC(a) _al_malloc(a)
68 #define _AL_FREE(a) _al_free(a)
69 #endif
70
71 using std::string;
72 using std::pair;
73
74 // extern bool debug;
75 extern int32_t hero_animation_speed; //lower is faster animation
76 extern zcmap *ZCMaps;
77 extern byte *colordata;
78 //extern byte *tilebuf;
79 extern tiledata *newtilebuf;
80 extern byte *trashbuf;
81 extern itemdata *itemsbuf;
82 extern wpndata *wpnsbuf;
83 extern comboclass *combo_class_buf;
84 extern guydata *guysbuf;
85 extern ZCHEATS zcheats;
86 extern zinitdata zinit;
87 extern char palnames[MAXLEVELS][17];
88 extern int32_t memrequested;
89 extern char *byte_conversion(int32_t number, int32_t format);
90 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
91 string zScript;
92 116 std::map<int32_t, script_slot_data > ffcmap;
93 116 std::map<int32_t, script_slot_data > globalmap;
94 116 std::map<int32_t, script_slot_data > genericmap;
95 116 std::map<int32_t, script_slot_data > itemmap;
96 116 std::map<int32_t, script_slot_data > npcmap;
97 116 std::map<int32_t, script_slot_data > ewpnmap;
98 116 std::map<int32_t, script_slot_data > lwpnmap;
99 116 std::map<int32_t, script_slot_data > playermap;
100 116 std::map<int32_t, script_slot_data > dmapmap;
101 116 std::map<int32_t, script_slot_data > screenmap;
102 116 std::map<int32_t, script_slot_data > itemspritemap;
103 116 std::map<int32_t, script_slot_data > comboscriptmap;
104 116 std::map<int32_t, script_slot_data > subscreenmap;
105 void free_newtilebuf();
106 bool combosread=false;
107 bool mapsread=false;
108 bool fixffcs=false;
109 bool fixpolsvoice=false;
110
111 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
112 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
113 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
114 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
115
116 char qstdat_string[2048] = { 0 };
117
118 static zinfo* load_tmp_zi = NULL;
119
120 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
121 const byte clavio[9]={97,109,111,110,103,117,115,0};
122
123 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
124 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
125
126 const char *qst_error[] =
127 {
128 "OK","File not found","Invalid quest file",
129 "Version not supported","Obsolete version",
130 "Missing new data" , /* but let it pass in ZQuest */
131 "Internal error occurred", "Invalid password",
132 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
133 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
134 };
135
136 //for legacy quests -DD
137 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
138 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
139 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
140 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
141 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
142 };
143
144 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
145
146
147 void delete_combo_aliases()
148 {
149 for(int32_t j(0); j<256; j++)
150 {
151 if(combo_aliases[j].combos != NULL)
152 {
153 delete[] combo_aliases[j].combos;
154 combo_aliases[j].combos=NULL;
155 }
156
157 if(combo_aliases[j].csets != NULL)
158 {
159 delete[] combo_aliases[j].csets;
160 combo_aliases[j].csets=NULL;
161 }
162 }
163
164 }
165
166 char *byte_conversion(int32_t number, int32_t format)
167 {
168 static char num_str[40];
169
170 if(format==-1) //auto
171 {
172 format=1; //bytes
173
174 if(number>1024)
175 {
176 format=2; //kilobytes
177 }
178
179 if(number>1024*1024)
180 {
181 format=3; //megabytes
182 }
183
184 if(number>1024*1024*1024)
185 {
186 format=4; //gigabytes (dude, what are you doing?)
187 }
188 }
189
190 switch(format)
191 {
192 case 1: //bytes
193 sprintf(num_str,"%db",number);
194 break;
195
196 case 2: //kilobytes
197 sprintf(num_str,"%.2fk",float(number)/1024);
198 break;
199
200 case 3: //megabytes
201 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
202 break;
203
204 case 4: //gigabytes
205 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
206 break;
207
208 default:
209 abort();
210 break;
211 }
212
213 return num_str;
214 }
215
216 1508 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
217 {
218 static char num_str1[40];
219 static char num_str2[40];
220 static char num_str[80];
221
222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1508 times.
1508 if(format1==-1) //auto
223 {
224 1508 format1=1; //bytes
225
226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1508 times.
1508 if(number1>1024)
227 {
228 1508 format1=2; //kilobytes
229 1508 }
230
231
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 464 times.
1508 if(number1>1024*1024)
232 {
233 464 format1=3; //megabytes
234 464 }
235
236
1/2
✓ Branch 0 taken 1508 times.
✗ Branch 1 not taken.
1508 if(number1>1024*1024*1024)
237 {
238 format1=4; //gigabytes (dude, what are you doing?)
239 }
240 1508 }
241
242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1508 times.
1508 if(format2==-1) //auto
243 {
244 1508 format2=1; //bytes
245
246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1508 times.
1508 if(number2>1024)
247 {
248 1508 format2=2; //kilobytes
249 1508 }
250
251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1508 times.
1508 if(number2>1024*1024)
252 {
253 1508 format2=3; //megabytes
254 1508 }
255
256
1/2
✓ Branch 0 taken 1508 times.
✗ Branch 1 not taken.
1508 if(number2>1024*1024*1024)
257 {
258 format2=4; //gigabytes (dude, what are you doing?)
259 }
260 1508 }
261
262
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1044 times.
✓ Branch 3 taken 464 times.
✗ Branch 4 not taken.
1508 switch(format1)
263 {
264 case 1: //bytes
265 sprintf(num_str1,"%db",number1);
266 break;
267
268 case 2: //kilobytes
269 1044 sprintf(num_str1,"%.2fk",float(number1)/1024);
270 1044 break;
271
272 case 3: //megabytes
273 464 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
274 464 break;
275
276 case 4: //gigabytes
277 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
278 break;
279
280 default:
281 abort();
282 break;
283 }
284
285
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1508 times.
✗ Branch 4 not taken.
1508 switch(format2)
286 {
287 case 1: //bytes
288 sprintf(num_str2,"%db",number2);
289 break;
290
291 case 2: //kilobytes
292 sprintf(num_str2,"%.2fk",float(number2)/1024);
293 break;
294
295 case 3: //megabytes
296 1508 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
297 1508 break;
298
299 case 4: //gigabytes
300 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
301 break;
302
303 default:
304 abort();
305 break;
306 }
307
308 1508 sprintf(num_str, "%s/%s", num_str1, num_str2);
309 1508 return num_str;
310 }
311
312 char *ordinal(int32_t num)
313 {
314 static const char *ending[4] = {"st","nd","rd","th"};
315 static char ord_str[8];
316
317 char *end;
318 int32_t t=(num%100)/10;
319 int32_t n=num%10;
320
321 if(n>=1 && n<4 && t!=1)
322 end = (char *)ending[n-1];
323 else
324 end = (char *)ending[3];
325
326 sprintf(ord_str,"%d%s",num%10000,end);
327 return ord_str;
328 }
329
330 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
331 {
332 int32_t ret;
333 *version=0;
334 *build=0;
335 byte temp_map_count=map_count;
336 byte temp_midi_flags[MIDIFLAGS_SIZE];
337 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
338
339 zquestheader tempheader;
340
341 if(!f)
342 {
343 return qe_invalid;
344 }
345
346 ret=readheader(f, &tempheader);
347
348 if(ret)
349 {
350 return ret;
351 }
352
353 map_count=temp_map_count;
354 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
355 *version=tempheader.zelda_version;
356 *build=tempheader.build;
357 return 0;
358 }
359
360
361 bool find_section(PACKFILE *f, int32_t section_id_requested)
362 {
363
364 if(!f)
365 {
366 return false;
367 }
368
369 int32_t section_id_read;
370 bool catchup=false;
371 word dummy;
372 byte tempbyte;
373 char tempbuf[65536];
374
375
376 switch(section_id_requested)
377 {
378 case ID_RULES:
379 case ID_STRINGS:
380 case ID_MISC:
381 case ID_TILES:
382 case ID_COMBOS:
383 case ID_CSETS:
384 case ID_MAPS:
385 case ID_DMAPS:
386 case ID_DOORS:
387 case ID_ITEMS:
388 case ID_WEAPONS:
389 case ID_COLORS:
390 case ID_ICONS:
391 case ID_INITDATA:
392 case ID_GUYS:
393 case ID_MIDIS:
394 case ID_CHEATS:
395 break;
396
397 default:
398 al_trace("Bad section requested!\n");
399 return false;
400 break;
401 }
402
403 dword section_size;
404
405 //section id
406 if(!p_mgetl(&section_id_read,f))
407 {
408 return false;
409 }
410
411 while(!pack_feof(f))
412 {
413 switch(section_id_read)
414 {
415 case ID_RULES:
416 case ID_STRINGS:
417 case ID_MISC:
418 case ID_TILES:
419 case ID_COMBOS:
420 case ID_CSETS:
421 case ID_MAPS:
422 case ID_DMAPS:
423 case ID_DOORS:
424 case ID_ITEMS:
425 case ID_WEAPONS:
426 case ID_COLORS:
427 case ID_ICONS:
428 case ID_INITDATA:
429 case ID_GUYS:
430 case ID_MIDIS:
431 case ID_CHEATS:
432 catchup=false;
433 break;
434
435 default:
436 break;
437 }
438
439
440 while(catchup)
441 {
442 //section id
443 section_id_read=(section_id_read<<8);
444
445 if(!p_getc(&tempbyte,f))
446 {
447 return false;
448 }
449
450 section_id_read+=tempbyte;
451 }
452
453 if(section_id_read==section_id_requested)
454 {
455 return true;
456 }
457 else
458 {
459 //section version info
460 if(!p_igetw(&dummy,f))
461 {
462 return false;
463 }
464
465 if(!p_igetw(&dummy,f))
466 {
467 return false;
468 }
469
470 //section size
471 if(!p_igetl(&section_size,f))
472 {
473 return false;
474 }
475
476 //pack_fseek(f, section_size);
477 while(section_size>65535)
478 {
479 pfread(tempbuf,65535,f);
480 tempbuf[65535]=0;
481 section_size-=65535;
482 }
483
484 if(section_size>0)
485 {
486 pfread(tempbuf,section_size,f);
487 tempbuf[section_size]=0;
488 }
489 }
490
491 //section id
492 if(!p_mgetl(&section_id_read,f))
493 {
494 return false;
495 }
496 }
497
498 return false;
499 }
500
501
502
503
504
505 bool valid_zqt(PACKFILE *f)
506 {
507
508 //word tiles_used;
509 //word combos_used;
510 //open the file
511 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
512 if(!f)
513 return false;
514
515 //for now, everything else is valid
516 return true;
517
518 /*int16_t version;
519 byte build;
520
521 //read the version and make sure it worked
522 if(!p_igetw(&version,f))
523 {
524 goto error;
525 }
526
527 //read the build and make sure it worked
528 if(!p_getc(&build,f))
529 goto error;
530
531 //read the tile info and make sure it worked
532 if(!p_igetw(&tiles_used,f))
533 {
534 goto error;
535 }
536
537 for (int32_t i=0; i<tiles_used; i++)
538 {
539 if(!pfread(trashbuf,tilesize(tf4Bit),f))
540 {
541 goto error;
542 }
543 }
544
545 //read the combo info and make sure it worked
546 if(!p_igetw(&combos_used,f))
547 {
548 goto error;
549 }
550 for (int32_t i=0; i<combos_used; i++)
551 {
552 if(!pfread(trashbuf,sizeof(newcombo),f))
553 {
554 goto error;
555 }
556 }
557
558 //read the palette info and make sure it worked
559 for (int32_t i=0; i<48; i++)
560 {
561 if(!pfread(trashbuf,newpdTOTAL,f))
562 {
563 goto error;
564 }
565 }
566 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
567 {
568 goto error;
569 }
570 for (int32_t i=0; i<MAXLEVELS; i++)
571 {
572 if(!pfread(trashbuf,PALNAMESIZE,f))
573 {
574 goto error;
575 }
576 }
577
578 //read the sprite info and make sure it worked
579 for (int32_t i=0; i<MAXITEMS; i++)
580 {
581 if(!pfread(trashbuf,sizeof(itemdata),f))
582 {
583 goto error;
584 }
585 }
586
587 for (int32_t i=0; i<MAXWPNS; i++)
588 {
589 if(!pfread(trashbuf,sizeof(wpndata),f))
590 {
591 goto error;
592 }
593 }
594
595 //read the triforce pieces info and make sure it worked
596 for (int32_t i=0; i<8; ++i)
597 {
598 if(!p_getc(&trashbuf,f))
599 {
600 goto error;
601 }
602 }
603
604
605
606 //read the game icons info and make sure it worked
607 for (int32_t i=0; i<4; ++i)
608 {
609 if(!p_igetw(&trashbuf,f))
610 {
611 goto error;
612 }
613 }
614
615 //read the misc colors info and map styles info and make sure it worked
616 if(!pfread(trashbuf,sizeof(zcolors),f))
617 {
618 goto error;
619 }
620
621 //read the template screens and make sure it worked
622 byte num_maps;
623 if(!p_getc(&num_maps,f))
624 {
625 goto error;
626 }
627 for (int32_t i=0; i<TEMPLATES; i++)
628 {
629 if(!pfread(trashbuf,sizeof(mapscr),f))
630 {
631 goto error;
632 }
633 }
634 if (num_maps>1) //dungeon templates
635 {
636 for (int32_t i=0; i<TEMPLATES; i++)
637 {
638 if(!pfread(trashbuf,sizeof(mapscr),f))
639 {
640 goto error;
641 }
642 }
643 }
644
645 //yay! it worked! close the file and say everything was ok.
646 pack_fclose(f);
647 return true;
648
649 error:
650 pack_fclose(f);
651 return false;*/
652 }
653
654 bool valid_zqt(const char *filename)
655 {
656 PACKFILE *f=NULL;
657 bool isvalid;
658 int32_t error;
659 f=open_quest_file(&error, filename, false);
660
661 if(!f)
662 {
663 // setPackfilePassword(NULL);
664 return false;
665 }
666
667 isvalid=valid_zqt(f);
668
669 clear_quest_tmpfile();
670 pack_fclose(f);
671
672 // setPackfilePassword(NULL);
673 return isvalid;
674 }
675
676 /*
677 .qst file history
678
679 .qst files have always been compressed using allegro's packfiles.
680
681 At some point, an encoding layer was added. The two layers look like this:
682
683 1) The top layer is from us. See decode_file_007.
684 [0-24] Preamble "Zelda Classic Quest File"
685 [25-28] Initial decoding seed value.
686 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
687 [last 4] Checksum
688
689 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
690 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
691 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
692 The oldest quests skip the password part.
693
694 Simply, the job of this function is to peel away the top layer.
695
696 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
697 in opening and saving files. There is no version field, so they decryption key is
698 found via trial-by-error (very slow!)
699
700 There are other file types of interest:
701 - .zqt: quest template files, skips top-layer encryption pass
702 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
703 - .qu?: same as above. automated backup files
704 - .qb?: same as above. automated backup files
705 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
706
707 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
708 files are now "slh!.AG ZC Enhanced Quest File".
709 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
710 */
711 130 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
712 {
713
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if (show_progress)
714 {
715 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
716 }
717
718 130 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
719
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 3 times.
130 if (unencrypted_result.decoded_pf)
720 127 return unencrypted_result.decoded_pf;
721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (unencrypted_result.not_found)
722 {
723 *open_error = qe_notfound;
724 return nullptr;
725 }
726
727 // Everything below here is legacy code - recently saved quest files will have
728 // returned by now.
729 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
730
731 // Note: although this is primarily for loading .qst files, it can also handle all of the
732 // file types mentioned in the comment above. No need to be told if the file being loaded
733 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
734 3 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
735 3 bool compressed = unencrypted_result.compressed;
736 3 bool encrypted = unencrypted_result.encrypted;
737
738 char tmpfilename[L_tmpnam];
739 3 temp_name(tmpfilename);
740 char percent_done[30];
741 3 int32_t current_method=0;
742
743 PACKFILE *f;
744 3 const char *passwd= encrypted ? datapwd : "";
745
746 // oldquest flag is set when an unencrypted qst file is suspected.
747 3 bool oldquest = false;
748 int32_t ret;
749
750
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(strcmp(filename, "default.qst")!=0)
751 {
752 3 box_out(filename);
753 3 }
754 else
755 {
756 box_out("new quest"); // Or whatever
757 }
758 3 box_out("...");
759 3 box_eol();
760 3 box_eol();
761
762
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(encrypted)
763 {
764 3 box_out("Decrypting...");
765 3 box_save_x();
766 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
767
768
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret)
769 {
770 switch(ret)
771 {
772 case 1:
773 box_out("error.");
774 box_eol();
775 box_end(true);
776 *open_error=qe_notfound;
777 return NULL;
778
779 case 2:
780 box_out("error.");
781 box_eol();
782 box_end(true);
783 *open_error=qe_internal;
784 return NULL;
785 // be sure not to delete tmpfilename now...
786 }
787
788 if(ret==5) //old encryption?
789 {
790 current_method++;
791 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
792 box_out(percent_done);
793 box_load_x();
794 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
795 }
796
797 if(ret==5) //old encryption?
798 {
799 current_method++;
800 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
801 box_out(percent_done);
802 box_load_x();
803 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
804 }
805
806 if(ret==5) //old encryption?
807 {
808 current_method++;
809 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
810 box_out(percent_done);
811 box_load_x();
812 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
813 }
814
815 if(ret==5) //old encryption?
816 {
817 current_method++;
818 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
819 box_out(percent_done);
820 box_load_x();
821 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
822 }
823
824 if(ret)
825 {
826 oldquest = true;
827 passwd="";
828 }
829 }
830
831 3 box_out("okay.");
832 3 box_eol();
833 3 }
834 else
835 {
836 oldquest = true;
837 }
838
839 3 box_out("Opening...");
840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
841
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!f)
842 {
843 if((compressed==1)&&(errno==EDOM))
844 {
845 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
846 }
847
848 if(!f)
849 {
850 if(!oldquest)
851 {
852 delete_file(tmpfilename);
853 }
854 box_out("error.");
855 box_eol();
856 box_end(true);
857 *open_error=qe_invalid;
858 return NULL;
859 }
860 }
861
862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!oldquest)
863 {
864 3 delete_file(tmpfilename);
865 3 }
866
867 3 box_out("okay.");
868 3 box_eol();
869
870 3 return f;
871 130 }
872
873 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
874 {
875 char *filename;
876 PACKFILE *f=NULL;
877 int32_t open_error=0;
878
879 strcpy(qstdat_string, "modules/classic/default.qst");
880 if(Header->templatepath[0]==0)
881 {
882 filename=(char *)malloc(2048);
883 strcpy(filename, qstdat_string);
884 }
885 else
886 {
887 // TODO: should be safe to remove this, no one seems to use custom quest templates.
888 filename=Header->templatepath;
889 }
890
891 f=open_quest_file(&open_error, filename, false);
892
893 if(Header->templatepath[0]==0)
894 {
895 free(filename);
896 }
897
898 if(!f)
899 {
900 return NULL;
901 }
902
903 if(validate)
904 {
905 if(!valid_zqt(f))
906 {
907 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
908 pack_fclose(f);
909 clear_quest_tmpfile();
910 return NULL;
911 }
912 }
913
914 return f;
915 }
916
917 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
918 {
919 // We absolutely do not support loading from a template file to initialize data outside the editor.
920 // TODO: move this code into zq/
921 if (get_app_id() != App::zquest) return false;
922
923 combosread=false;
924 mapsread=false;
925 fixffcs=false;
926
927 switch(section_id)
928 {
929 case ID_RULES:
930 case ID_STRINGS:
931 case ID_MISC:
932 case ID_TILES:
933 case ID_COMBOS:
934 case ID_CSETS:
935 case ID_MAPS:
936 case ID_DMAPS:
937 case ID_DOORS:
938 case ID_ITEMS:
939 case ID_WEAPONS:
940 case ID_COLORS:
941 case ID_ICONS:
942 case ID_INITDATA:
943 case ID_GUYS:
944 case ID_MIDIS:
945 case ID_CHEATS:
946 case ID_ITEMDROPSETS:
947 case ID_FAVORITES:
948 break;
949
950 default:
951 return false;
952 break;
953 }
954
955 int32_t ret;
956 word version, build;
957 PACKFILE *f=NULL;
958
959 char deletefilename[1024];
960 deletefilename[0]=0;
961
962 //why is this here?
963 /*
964 if(colordata==NULL)
965 return false;
966 */
967
968 //setPackfilePassword(datapwd);
969 f=open_quest_template(Header, deletefilename, validate);
970
971 if(!f) //no file, nothing to delete
972 {
973 // setPackfilePassword(NULL);
974 return false;
975 }
976
977 ret=get_version_and_build(f, &version, &build);
978
979 if(ret||(version==0))
980 {
981 pack_fclose(f);
982 clear_quest_tmpfile();
983
984 if(deletefilename[0])
985 {
986 delete_file(deletefilename);
987 }
988
989 // setPackfilePassword(NULL);
990 return false;
991 }
992
993 if(!find_section(f, section_id))
994 {
995 al_trace("Can't find section!\n");
996 pack_fclose(f);
997 clear_quest_tmpfile();
998
999 if(deletefilename[0])
1000 {
1001 delete_file(deletefilename);
1002 }
1003
1004 //setPackfilePassword(NULL);
1005 return false;
1006 }
1007
1008 switch(section_id)
1009 {
1010 case ID_RULES:
1011 //rules
1012 ret=readrules(f, Header);
1013 break;
1014
1015 case ID_STRINGS:
1016 //strings
1017 ret=readstrings(f, Header);
1018 break;
1019
1020 case ID_MISC:
1021 //misc data
1022 ret=readmisc(f, Header, Misc);
1023 break;
1024
1025 case ID_TILES:
1026 //tiles
1027 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1028 break;
1029
1030 case ID_COMBOS:
1031 //combos
1032 clear_combos();
1033 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1034 combosread=true;
1035 break;
1036
1037 case ID_COMBOALIASES:
1038 //combos
1039 ret=readcomboaliases(f, Header, version, build);
1040 break;
1041
1042 case ID_CSETS:
1043 //color data
1044 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1045 break;
1046
1047 case ID_MAPS:
1048 //maps
1049 ret=readmaps(f, Header);
1050 mapsread=true;
1051 break;
1052
1053 case ID_DMAPS:
1054 //dmaps
1055 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1056 break;
1057
1058 case ID_DOORS:
1059 //door combo sets
1060 ret=readdoorcombosets(f, Header);
1061 break;
1062
1063 case ID_ITEMS:
1064 //items
1065 ret=readitems(f, version, build);
1066 break;
1067
1068 case ID_WEAPONS:
1069 //weapons
1070 ret=readweapons(f, Header);
1071 break;
1072
1073 case ID_COLORS:
1074 //misc. colors
1075 ret=readmisccolors(f, Header, Misc);
1076 break;
1077
1078 case ID_ICONS:
1079 //game icons
1080 ret=readgameicons(f, Header, Misc);
1081 break;
1082
1083 case ID_INITDATA:
1084 //initialization data
1085 ret=readinitdata(f, Header);
1086 break;
1087
1088 case ID_GUYS:
1089 //guys
1090 ret=readguys(f, Header);
1091 break;
1092
1093 case ID_MIDIS:
1094 //midis
1095 ret=readtunes(f, Header, tunes);
1096 break;
1097
1098 case ID_CHEATS:
1099 //cheat codes
1100 ret=readcheatcodes(f, Header);
1101 break;
1102
1103 case ID_ITEMDROPSETS:
1104 //item drop sets
1105 // Why is this one commented out?
1106 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1107 break;
1108
1109 case ID_FAVORITES:
1110 // favorite combos and aliases
1111 ret=readfavorites(f, version, build);
1112 break;
1113
1114 default:
1115 ret=-1;
1116 break;
1117 }
1118
1119 pack_fclose(f);
1120 clear_quest_tmpfile();
1121
1122 if(deletefilename[0])
1123 {
1124 delete_file(deletefilename);
1125 }
1126
1127 //setPackfilePassword(NULL);
1128 if(!ret)
1129 {
1130 return true;
1131 }
1132
1133 return false;
1134 }
1135
1136 bool init_tiles(bool validate, zquestheader *Header)
1137 {
1138 return init_section(Header, ID_TILES, NULL, NULL, validate);
1139 }
1140
1141 bool init_combos(bool validate, zquestheader *Header)
1142 {
1143 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1144 }
1145
1146 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1147 {
1148 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1149 }
1150
1151 130 void init_spritelists()
1152 {
1153
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 37 times.
130 if(FFCore.quest_format[vZelda] < 0x255)
1154 {
1155 93 guys.setMax(255);
1156 93 items.setMax(255);
1157 93 Ewpns.setMax(255);
1158 93 Lwpns.setMax(255);
1159 93 chainlinks.setMax(255);
1160 93 decorations.setMax(255);
1161 93 particles.setMax(255);
1162 93 }
1163 else
1164 {
1165 37 guys.setMax(255);
1166 37 items.setMax(255);
1167 37 Ewpns.setMax(255);
1168 37 Lwpns.setMax(255);
1169 37 chainlinks.setMax(255);
1170 37 decorations.setMax(255);
1171 37 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1172 }
1173 130 }
1174
1175 116 bool reset_items(bool validate, zquestheader *Header)
1176 {
1177 116 bool ret = true;
1178
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if (get_app_id() == App::zquest)
1179 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1180
1181
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29696 times.
29812 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1182
1183 116 return ret;
1184 }
1185
1186 bool reset_guys()
1187 {
1188 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1189 init_guys(V_GUYS);
1190 return true;
1191 }
1192
1193 bool reset_wpns(bool validate, zquestheader *Header)
1194 {
1195 bool ret = true;
1196 if (get_app_id() == App::zquest)
1197 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1198
1199 for(int32_t i=0; i<MAXWPNS; i++)
1200 reset_weaponname(i);
1201
1202 return ret;
1203 }
1204
1205 bool reset_mapstyles(bool validate, miscQdata *Misc)
1206 {
1207 Misc->colors.blueframe_tile = 20044;
1208 Misc->colors.blueframe_cset = 0;
1209 Misc->colors.triforce_tile = 23461;
1210 Misc->colors.triforce_cset = 1;
1211 Misc->colors.triframe_tile = 18752;
1212 Misc->colors.triframe_cset = 1;
1213 Misc->colors.overworld_map_tile = 16990;
1214 Misc->colors.overworld_map_cset = 2;
1215 Misc->colors.HCpieces_tile = 21160;
1216 Misc->colors.HCpieces_cset = 8;
1217 Misc->colors.dungeon_map_tile = 19651;
1218 Misc->colors.dungeon_map_cset = 8;
1219 return true;
1220 }
1221
1222 116 int32_t get_qst_buffers()
1223 {
1224 116 memrequested+=(sizeof(mapscr)*MAPSCRS);
1225 116 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1226 116 TheMaps.resize(MAPSCRS);
1227 116 map_autolayers.resize(6);
1228
1229
2/2
✓ Branch 0 taken 15776 times.
✓ Branch 1 taken 116 times.
15892 for(int32_t i(0); i<MAPSCRS; i++)
1230 15776 TheMaps[i].zero_memory();
1231
1232 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1233 116 Z_message("OK\n"); // Allocating map buffer...
1234
1235 116 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1236 116 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1237
1238
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1239 return 0;
1240
1241 116 Z_message("OK\n");
1242
1243 // Allocating space for all 65535 strings uses up 10.62MB...
1244 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1245 // (Shoelace's "Hero of Dreams" uses 1415.)
1246 // So let's be a bit generous and allow 4096 initially.
1247 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1248 // I tested it and it worked without flaw on 6/6/11. - L.
1249 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1250 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1251 // See https://discord.com/channels/876899628556091432/992984989073416242
1252 116 msg_strings_size = 8192;
1253 116 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1254 116 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1255
1256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 MsgStrings = new MsgStr[msg_strings_size];
1257
1258 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1259
2/2
✓ Branch 0 taken 950272 times.
✓ Branch 1 taken 116 times.
950388 for(auto q = 0; q < msg_strings_size; ++q)
1260 {
1261 950272 MsgStrings[q].clear();
1262 950272 }
1263 116 Z_message("OK\n"); // Allocating string buffer...
1264
1265 116 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1266 116 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1267
1268
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1269 return 0;
1270
1271 116 Z_message("OK\n"); // Allocating door combo buffer...
1272
1273 116 memrequested+=(sizeof(dmap)*MAXDMAPS);
1274 116 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1275
1276
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1277 return 0;
1278
1279 116 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1280 116 Z_message("OK\n"); // Allocating dmap buffer...
1281
1282 116 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1283 116 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1284
1285 116 combobuf.clear();
1286 116 combobuf.resize(MAXCOMBOS);
1287 116 Z_message("OK\n"); // Allocating combo buffer...
1288
1289 116 memrequested+=(psTOTAL255);
1290 116 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1291
1292
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1293 return 0;
1294
1295 116 Z_message("OK\n"); // Allocating color data buffer...
1296
1297 116 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1298 116 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1299
1300 116 free_newtilebuf();
1301
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1302 return 0;
1303
1304 116 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1305 //Z_message("Performed memset on tiles\n");
1306 116 clear_tiles(newtilebuf);
1307 //Z_message("Performed clear_tiles()\n");
1308 116 Z_message("OK\n"); // Allocating tile buffer...
1309
1310
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(is_editor())
1311 {
1312 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1313 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1314
1315 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1316 return 0;
1317
1318 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1319 clear_tiles(grabtilebuf);
1320 Z_message("OK\n"); // Allocating tile grab buffer...
1321 }
1322
1323 116 memrequested+=(100000);
1324 116 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1325
1326
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((trashbuf=(byte*)malloc(100000))==NULL)
1327 return 0;
1328
1329 116 Z_message("OK\n"); // Allocating trash buffer...
1330
1331 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1332 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1333 // fixed by ensuring there's actually itemdata there.
1334 // If you change this, be sure to update del_qst_buffers, too.
1335
1336 116 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1337 116 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1338
1339
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1340 return 0;
1341
1342 116 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1343 116 itemsbuf++;
1344 116 Z_message("OK\n"); // Allocating item buffer...
1345
1346 116 memrequested+=(sizeof(wpndata)*MAXWPNS);
1347 116 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1348
1349
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1350 return 0;
1351
1352 116 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1353 116 Z_message("OK\n"); // Allocating weapon buffer...
1354
1355 116 memrequested+=(sizeof(guydata)*MAXGUYS);
1356 116 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1357
1358
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1359 return 0;
1360
1361 116 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1362 116 Z_message("OK\n"); // Allocating guy buffer...
1363
1364 116 memrequested+=(sizeof(comboclass)*cMAX);
1365 116 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1366
1367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1368 return 0;
1369
1370 116 Z_message("OK\n"); // Allocating combo class buffer...
1371
1372 116 return 1;
1373 116 }
1374
1375
1376 116 void free_newtilebuf()
1377 {
1378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(newtilebuf)
1379 {
1380 for(int32_t i=0; i<NEWMAXTILES; i++)
1381 if(newtilebuf[i].data)
1382 free(newtilebuf[i].data);
1383
1384 free(newtilebuf);
1385 newtilebuf = 0;
1386 }
1387 116 }
1388
1389 void free_grabtilebuf()
1390 {
1391 if(is_editor())
1392 {
1393 if(grabtilebuf)
1394 {
1395 for(int32_t i=0; i<NEWMAXTILES; i++)
1396 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1397
1398 free(grabtilebuf);
1399 grabtilebuf = 0;
1400 }
1401 }
1402 }
1403
1404 void del_qst_buffers()
1405 {
1406 al_trace("Cleaning maps. \n");
1407
1408 if(ZCMaps) free(ZCMaps);
1409
1410 if(MsgStrings) delete[] MsgStrings;
1411
1412 if(DoorComboSets) free(DoorComboSets);
1413
1414 if(DMaps) free(DMaps);
1415
1416 combobuf.clear();
1417
1418 if(colordata) free(colordata);
1419
1420 al_trace("Cleaning tile buffers. \n");
1421 free_newtilebuf();
1422 free_grabtilebuf();
1423
1424 al_trace("Cleaning misc. \n");
1425
1426 if(trashbuf) free(trashbuf);
1427
1428 // See get_qst_buffers
1429 if(itemsbuf)
1430 {
1431 itemsbuf--;
1432 free(itemsbuf);
1433 }
1434
1435 if(wpnsbuf) free(wpnsbuf);
1436
1437 if(guysbuf) free(guysbuf);
1438
1439 if(combo_class_buf) free(combo_class_buf);
1440 }
1441
1442 4 bool init_palnames()
1443 {
1444 // if(palnames==NULL)
1445 // return false;
1446
1447
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t x=0; x<MAXLEVELS; x++)
1448 {
1449
4/4
✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
2048 switch(x)
1450 {
1451 case 0:
1452 4 sprintf(palnames[x],"Overworld");
1453 4 break;
1454
1455 case 10:
1456 4 sprintf(palnames[x],"Caves");
1457 4 break;
1458
1459 case 11:
1460 4 sprintf(palnames[x],"Passageways");
1461 4 break;
1462
1463 default:
1464 2036 sprintf(palnames[x],"%c",0);
1465 2036 break;
1466 }
1467 2048 }
1468
1469 4 return true;
1470 }
1471
1472 25212 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1473 {
1474 void *p;
1475
1476
1/2
✓ Branch 0 taken 25212 times.
✗ Branch 1 not taken.
25212 p = _AL_MALLOC(MAX(size, alloc_size));
1477
1478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25212 times.
25212 if(!p)
1479 {
1480 return NULL;
1481 }
1482
1483
1/2
✓ Branch 0 taken 25212 times.
✗ Branch 1 not taken.
25212 if(!pfread(p,size,f))
1484 {
1485 _AL_FREE(p);
1486 return NULL;
1487 }
1488
1489
1/2
✓ Branch 0 taken 25212 times.
✗ Branch 1 not taken.
25212 if(pack_ferror(f))
1490 {
1491 _AL_FREE(p);
1492 return NULL;
1493 }
1494
1495 25212 return p;
1496 25212 }
1497
1498 /* read_midi:
1499 * Reads MIDI data from a datafile (this is not the same thing as the
1500 * standard midi file format).
1501 */
1502
1503 2303 static MIDI *read_midi(PACKFILE *f)
1504 {
1505 MIDI *m;
1506 int32_t c;
1507 2303 int16_t divisions=0;
1508 2303 int32_t len=0;
1509
1510 2303 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1511
1512
1/2
✓ Branch 0 taken 2303 times.
✗ Branch 1 not taken.
2303 if(!m)
1513 {
1514 return NULL;
1515 }
1516
1517
2/2
✓ Branch 0 taken 73696 times.
✓ Branch 1 taken 2303 times.
75999 for(c=0; c<MIDI_TRACKS; c++)
1518 {
1519 73696 m->track[c].len = 0;
1520 73696 m->track[c].data = NULL;
1521 73696 }
1522
1523 2303 p_mgetw(&divisions,f);
1524 2303 m->divisions=divisions;
1525
1526
2/2
✓ Branch 0 taken 73696 times.
✓ Branch 1 taken 2303 times.
75999 for(c=0; c<MIDI_TRACKS; c++)
1527 {
1528 73696 p_mgetl(&len,f);
1529 73696 m->track[c].len=len;
1530
1531
2/2
✓ Branch 0 taken 48484 times.
✓ Branch 1 taken 25212 times.
73696 if(m->track[c].len > 0)
1532 {
1533 25212 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1534
1535
1/2
✓ Branch 0 taken 25212 times.
✗ Branch 1 not taken.
25212 if(!m->track[c].data)
1536 {
1537 destroy_midi(m);
1538 return NULL;
1539 }
1540 25212 }
1541 73696 }
1542
1543 LOCK_DATA(m, sizeof(MIDI));
1544
1545
2/2
✓ Branch 0 taken 73696 times.
✓ Branch 1 taken 2303 times.
75999 for(c=0; c<MIDI_TRACKS; c++)
1546 {
1547
2/2
✓ Branch 0 taken 25212 times.
✓ Branch 1 taken 48484 times.
73696 if(m->track[c].data)
1548 {
1549 LOCK_DATA(m->track[c].data, m->track[c].len);
1550 25212 }
1551 73696 }
1552
1553 2303 return m;
1554 2303 }
1555
1556 void clear_combo(int32_t i)
1557 {
1558 combobuf[i].clear();
1559 }
1560
1561 void clear_combos()
1562 {
1563 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1564 clear_combo(tmpcounter);
1565 }
1566
1567 void pack_combos()
1568 {
1569 int32_t di = 0;
1570
1571 for(int32_t si=0; si<1024; si+=2)
1572 combobuf[di++] = combobuf[si];
1573
1574 for(; di<1024; di++)
1575 clear_combo(di);
1576 }
1577
1578 130 void reset_tunes(zctune *tune)
1579 {
1580
2/2
✓ Branch 0 taken 32760 times.
✓ Branch 1 taken 130 times.
32890 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1581 {
1582 32760 tune[i].reset();
1583 32760 }
1584 130 }
1585
1586
1587 /*void reset_midi(zcmidi_ *m)
1588 {
1589 m->title[0]=0;
1590 m->loop=1;
1591 m->volume=144;
1592 m->start=0;
1593 m->loop_start=-1;
1594 m->loop_end=-1;
1595 if(m->midi)
1596 {
1597 destroy_midi(m->midi);
1598 }
1599 m->midi=NULL;
1600 }
1601
1602
1603 void reset_midis(zcmidi_ *m)
1604 {
1605 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1606 {
1607 reset_midi(m+i);
1608 }
1609 }
1610 */
1611
1612 void reset_scr(int32_t scr)
1613 {
1614 /*
1615 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1616 for(unsigned i=0; i<sizeof(mapscr); i++)
1617 *(di++) = 0;
1618 TheMaps[scr].valid=mVERSION;
1619 */
1620
1621 TheMaps[scr].zero_memory();
1622 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1623
1624 for(int32_t i=0; i<6; i++)
1625 {
1626 //these will be uncommented later
1627 //TheMaps[scr].layerxsize[i]=16;
1628 //TheMaps[scr].layerysize[i]=11;
1629 TheMaps[scr].layeropacity[i]=255;
1630 }
1631
1632 TheMaps[scr].valid=mVERSION;
1633
1634 }
1635
1636 /* For reference:
1637
1638 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1639 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1640 */
1641
1642 3574 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1643 {
1644
2/2
✓ Branch 0 taken 16422 times.
✓ Branch 1 taken 1606 times.
18028 for(int32_t i=0; i<9; i++)
1645 {
1646
2/2
✓ Branch 0 taken 88692 times.
✓ Branch 1 taken 14454 times.
103146 for(int32_t j=0; j<6; j++)
1647 {
1648
2/2
✓ Branch 0 taken 28908 times.
✓ Branch 1 taken 59784 times.
88692 if(j<4)
1649 {
1650
2/2
✓ Branch 0 taken 57816 times.
✓ Branch 1 taken 1968 times.
59784 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1651 {
1652 1968 return false;
1653 }
1654
1655
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1656 {
1657 return false;
1658 }
1659
1660
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1661 {
1662 return false;
1663 }
1664
1665
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1666 {
1667 return false;
1668 }
1669 57816 }
1670
1671
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1672 {
1673 return false;
1674 }
1675
1676
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1677 {
1678 return false;
1679 }
1680
1681
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1682 {
1683 return false;
1684 }
1685
1686
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1687 {
1688 return false;
1689 }
1690 86724 }
1691
1692
2/2
✓ Branch 0 taken 11242 times.
✓ Branch 1 taken 3212 times.
14454 if(i<2)
1693 {
1694
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.flags[i]!=b.flags[i])
1695 {
1696 return false;
1697 }
1698
1699
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1700 {
1701 return false;
1702 }
1703
1704
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1705 {
1706 return false;
1707 }
1708
1709
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1710 {
1711 return false;
1712 }
1713
1714
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1715 {
1716 return false;
1717 }
1718 3212 }
1719
1720
2/2
✓ Branch 0 taken 9636 times.
✓ Branch 1 taken 4818 times.
14454 if(i<3)
1721 {
1722
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1723 {
1724 return false;
1725 }
1726
1727
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1728 {
1729 return false;
1730 }
1731
1732
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1733 {
1734 return false;
1735 }
1736
1737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4818 times.
4818 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1738 {
1739 return false;
1740 }
1741 4818 }
1742
1743
1/2
✓ Branch 0 taken 14454 times.
✗ Branch 1 not taken.
14454 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1744 {
1745 return false;
1746 }
1747
1748
1/2
✓ Branch 0 taken 14454 times.
✗ Branch 1 not taken.
14454 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1749 {
1750 return false;
1751 }
1752 14454 }
1753
1754 1606 return true;
1755 3574 }
1756
1757 int32_t doortranslations_u[9][4]=
1758 {
1759 {37,38,53,54},
1760 {37,38,39,40},
1761 {37,38,55,56},
1762 {37,38,39,40},
1763 {37,38,53,54},
1764 {37,38,53,54},
1765 {37,38,53,54},
1766 {7,8,23,24},
1767 {7,8,41,42}
1768 };
1769
1770 int32_t doortranslations_d[9][4]=
1771 {
1772 {117,118,133,134},
1773 {135,136,133,134},
1774 {119,120,133,134},
1775 {135,136,133,134},
1776 {117,118,133,134},
1777 {117,118,133,134},
1778 {117,118,133,134},
1779 {151,152,167,168},
1780 {137,138,167,168},
1781 };
1782
1783 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1784 int32_t doortranslations_l[9][6]=
1785 {
1786 {66,67,82,83,98,99},
1787 {66,68,82,84,98,100},
1788 {66,69,82,85,98,101},
1789 {66,68,82,84,98,100},
1790 {66,67,82,83,98,99},
1791 {66,67,82,83,98,99},
1792 {66,67,82,83,98,99},
1793 {64,65,80,81,96,97},
1794 {64,65,80,114,96,97},
1795 };
1796
1797 int32_t doortranslations_r[9][6]=
1798 {
1799
1800 {76,77,92,93,108,109},
1801 {75,77,91,93,107,109},
1802 {74,77,90,93,106,109},
1803 {75,77,91,93,107,109},
1804 {76,77,92,93,108,109},
1805 {76,77,92,93,108,109},
1806 {76,77,92,93,108,109},
1807 {78,79,94,95,110,111},
1808 {78,79,125,95,110,111},
1809 };
1810
1811 314668 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1812 {
1813 314668 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1814 }
1815
1816 308180 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1817 {
1818 //these are here to bypass compiler warnings about unused arguments
1819 308180 map=map;
1820 308180 scr=scr;
1821 308180 pos=pos;
1822
1823 //what does this function do?
1824 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1825 308180 return 2;
1826 }
1827
1828 7072 int32_t MakeDoors(int32_t map, int32_t scr)
1829 {
1830
2/2
✓ Branch 0 taken 5450 times.
✓ Branch 1 taken 1622 times.
7072 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1831 {
1832 5450 return 0;
1833 }
1834
1835 DoorComboSet tempdcs;
1836 1622 memset(&tempdcs, 0, sizeof(DoorComboSet));
1837
1838 //up
1839
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1840 {
1841
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1842 {
1843 58392 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1844 58392 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1845 58392 }
1846 14598 }
1847
1848 1622 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1849 1622 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1850 1622 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1851 1622 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1852 1622 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1853 1622 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1854
1855 //down
1856
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1857 {
1858
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1859 {
1860 58392 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1861 58392 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1862 58392 }
1863 14598 }
1864
1865 1622 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1866
1867 1622 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1868 1622 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1869 1622 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1870 1622 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1871 1622 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1872
1873 //left
1874 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1875
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1876 {
1877
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1878 {
1879 87588 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1880 87588 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1881 87588 }
1882 14598 }
1883
1884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1885 {
1886 if((j!=2)&&(j!=3))
1887 {
1888 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1889 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1890 }
1891 }
1892
1893 1622 tempdcs.bombdoorcombo_l[0]=0;
1894 1622 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1895 1622 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1896 1622 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1897 1622 tempdcs.bombdoorcombo_l[2]=0;
1898 1622 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1899 1622 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1900 1622 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1901
1902 //right
1903
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1904 {
1905
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1906 {
1907 87588 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1908 87588 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1909 87588 }
1910 14598 }
1911
1912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1913 {
1914 if((j!=2)&&(j!=3))
1915 {
1916 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1917 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1918 }
1919 }
1920
1921 1622 tempdcs.bombdoorcombo_r[0]=0;
1922 1622 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1923 1622 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1924 1622 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1925 1622 tempdcs.bombdoorcombo_r[2]=0;
1926 1622 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1927 1622 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1928 1622 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1929
1930 int32_t k;
1931
1932
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 3574 times.
3590 for(k=0; k<door_combo_set_count; k++)
1933 {
1934
2/2
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 1968 times.
3574 if(DoorComboSets[k]==tempdcs)
1935 {
1936 1606 break;
1937 }
1938 1968 }
1939
1940
2/2
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 16 times.
1622 if(k==door_combo_set_count)
1941 {
1942 16 DoorComboSets[k]=tempdcs;
1943 16 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
1944 16 ++door_combo_set_count;
1945 16 }
1946
1947 1622 return k;
1948 /*
1949 doorcombo_u[9][4];
1950 doorcset_u[9][4];
1951 doorcombo_d[9][4];
1952 doorcset_d[9][4];
1953 doorcombo_l[9][6];
1954 doorcset_l[9][6];
1955 doorcombo_r[9][6];
1956 doorcset_r[9][6];
1957 bombdoorcombo_u[2];
1958 bombdoorcset_u[2];
1959 bombdoorcombo_d[2];
1960 bombdoorcset_d[2];
1961 bombdoorcombo_l[3];
1962 bombdoorcset_l[3];
1963 bombdoorcombo_r[3];
1964 bombdoorcset_r[3];
1965 walkthroughcombo[4];
1966 walkthroughcset[4];
1967 */
1968 7072 }
1969
1970 905216 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1971 {
1972 905216 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1973 }
1974
1975 905216 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1976 {
1977
1978 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1979 }
1980
1981 905216 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1982 {
1983 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1984 }
1985
1986
1987 16 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1988 {
1989 char temp_pwd[30];
1990 16 memset(temp_pwd,0,30);
1991
1992
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(pwdkey!=0)
1993 {
1994 16 memcpy(temp_pwd,encrypted_pwd,30);
1995 16 temp_pwd[29]=0;
1996
1997
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 16 times.
496 for(int32_t i=0; i<30; i++)
1998 {
1999 480 temp_pwd[i] -= pwdkey;
2000 480 int32_t t=pwdkey>>15;
2001 480 pwdkey = (pwdkey<<1)+t;
2002 480 }
2003 16 }
2004
2005 16 memcpy(pwd,temp_pwd,30);
2006 16 }
2007
2008
2009 92 bool devpwd()
2010 {
2011 #ifdef _DEBUG
2012 return true;
2013 #endif
2014 92 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio);
2015 }
2016 bool check_questpwd(zquestheader *Header, char *pwd)
2017 {
2018 #if DEVLEVEL > 3
2019 return true;
2020 #endif
2021
2022 if (devpwd()) return true;
2023 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2024 cvs_MD5Context ctx;
2025 uint8_t md5sum[16];
2026
2027 cvs_MD5Init(&ctx);
2028 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2029 cvs_MD5Final(md5sum, &ctx);
2030
2031 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2032 }
2033
2034 122 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2035 {
2036 122 zprint2("\n");
2037 122 zprint2("[ZQUEST CREATOR METADATA]\n");
2038
1/2
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
122 if(qst_num < moduledata.max_quest_files)
2039 zprint2("Loading module quest %d\n", qst_num+1);
2040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 122 times.
122 if(path) zprint2("Loading '%s'\n", path);
2041
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 4 times.
122 if ( tempheader.new_version_id_main > 0 )
2042 {
2043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if(tempheader.new_version_id_fourth > 0)
2044 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2045 tempheader.new_version_id_main,tempheader.new_version_id_second,
2046 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2047 118 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2048 118 tempheader.new_version_id_main,tempheader.new_version_id_second,
2049 118 tempheader.new_version_id_third);
2050 118 }
2051 else
2052 {
2053
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 switch ( tempheader.zelda_version )
2054 {
2055 case 0x255:
2056 {
2057 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2058 break;
2059 }
2060 case 0x254:
2061 {
2062 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2063 break;
2064 }
2065 case 0x250:
2066 {
2067 switch(tempheader.build)
2068 {
2069 case 19:
2070 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2071 case 20:
2072 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2073 case 21:
2074 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2075 case 22:
2076 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2077 case 23:
2078 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2079 case 24:
2080 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2081 case 25:
2082 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2083 case 26:
2084 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2085 case 27:
2086 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2087 case 28:
2088 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2089 case 29:
2090 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2091 case 30:
2092 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2093 case 31:
2094 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2095 case 32:
2096 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2097 case 33:
2098 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2099 default:
2100 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2101
2102 }
2103 break;
2104 }
2105
2106 case 0x211:
2107 {
2108 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2109 }
2110 case 0x210:
2111 {
2112 zprint2("Last saved in ZQuest Version: 2.10.x");
2113 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2114 break;
2115 }
2116 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2117 case 0x193:
2118 {
2119 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2120 }
2121 case 0x192:
2122 {
2123 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2124 }
2125 case 0x190:
2126 {
2127 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2128 }
2129 case 0x184:
2130 {
2131 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2132 }
2133 case 0x183:
2134 {
2135 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2136 }
2137 case 0x180:
2138 {
2139 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2140 }
2141 default:
2142 {
2143 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2144 }
2145 */
2146 }
2147 }
2148
3/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
122 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2149 29 zprint2("%s\n", tempheader.getAlphaVerStr());
2150 93 else zprint2("\n");
2151
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 29 times.
122 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2152
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 29 times.
122 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2153
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 29 times.
122 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2154
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 29 times.
122 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2155
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 118 times.
122 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2156
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 29 times.
122 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2157 122 zprint2("\n");
2158 122 }
2159
2160 130 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
2161 {
2162 int32_t dummy;
2163 zquestheader tempheader;
2164 char dummybuf[80];
2165 byte temp_map_count;
2166 byte temp_midi_flags[MIDIFLAGS_SIZE];
2167 word version;
2168 char temp_pwd[30], temp_pwd2[30];
2169 int16_t temp_pwdkey;
2170 cvs_MD5Context ctx;
2171 130 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2172 130 memset(&tempheader, 0, sizeof(tempheader));
2173 130 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2174
2175
2176
2177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
2178 {
2179 Z_message("Unable to read header string\n");
2180 return qe_invalid;
2181 }
2182
2183 // check header
2184
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2185 {
2186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2187 {
2188 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2189 return qe_invalid;
2190 }
2191 4 }
2192
2193 130 int32_t templatepath_len=0;
2194
2195 130 tempheader.external_zinfo = false;
2196 130 read_zinfo = false;
2197
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2198 {
2199 byte padding;
2200
2201
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2202 {
2203 return qe_invalid;
2204 }
2205
2206
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.zelda_version,f))
2207 {
2208 return qe_invalid;
2209 }
2210
2211 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2212
2213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version > ZELDA_VERSION)
2214 {
2215 return qe_version;
2216 }
2217
2218 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2219
2220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2221 {
2222 return qe_invalid;
2223 }
2224
2225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(bad_version(tempheader.zelda_version))
2226 {
2227 return qe_obsolete;
2228 }
2229
2230
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.internal,f))
2231 {
2232 return qe_invalid;
2233 }
2234
2235
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.quest_number,f))
2236 {
2237 return qe_invalid;
2238 }
2239
2240 4 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2241
2242
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[0],2,f))
2243 {
2244 return qe_invalid;
2245 }
2246
2247
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_map_count,f))
2248 {
2249 return qe_invalid;
2250 }
2251
2252 4 FFCore.quest_format[qMapCount] = temp_map_count;
2253
2254
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.old_str_count,f))
2255 {
2256 return qe_invalid;
2257 }
2258
2259
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2260 {
2261 return qe_invalid;
2262 }
2263
2264
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_midi_flags,4,f))
2265 {
2266 return qe_invalid;
2267 }
2268
2269
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2270 {
2271 return qe_invalid;
2272 }
2273
2274
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,14,f))
2275 {
2276 return qe_invalid;
2277 }
2278
2279
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[2],2,f))
2280 {
2281 return qe_invalid;
2282 }
2283
2284
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&dummybuf,f))
2285 {
2286 return qe_invalid;
2287 }
2288
2289
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.version,9,f))
2290 {
2291 return qe_invalid;
2292 }
2293
2294
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2295 {
2296 return qe_invalid;
2297 }
2298 // These fields are expected to end in null bytes!
2299 4 tempheader.title[sizeof(tempheader.title)-1] = 0;
2300
2301
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2302 {
2303 return qe_invalid;
2304 }
2305 4 tempheader.author[sizeof(tempheader.author)-1] = 0;
2306
2307
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2308 {
2309 return qe_invalid;
2310 }
2311
2312
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_pwdkey,f))
2313 {
2314 return qe_invalid;
2315 }
2316
2317
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_pwd,30,f))
2318 {
2319 return qe_invalid;
2320 }
2321
2322 4 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2323 4 cvs_MD5Init(&ctx);
2324 4 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2325 4 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2326
2327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2328 {
2329 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2330 // Not anymore...
2331 memset(tempheader.minver,0,17);
2332 tempheader.build=0;
2333 tempheader.use_keyfile=0;
2334 memset(tempheader.old_foo, 0, 9);
2335 }
2336 else
2337 {
2338
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.minver,9,f))
2339 {
2340 return qe_invalid;
2341 }
2342
2343
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.build,f))
2344 {
2345 return qe_invalid;
2346 }
2347
2348 4 FFCore.quest_format[vBuild] = tempheader.build;
2349
2350
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.use_keyfile,f))
2351 {
2352 return qe_invalid;
2353 }
2354
2355
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,9,f))
2356 {
2357 return qe_invalid;
2358 }
2359 } // starting at minver
2360
2361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2362 {
2363 memset(&quest_rules[4],0,16); // word rules3..rules10
2364 }
2365 else
2366 {
2367
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2368 {
2369 return qe_invalid; // starting at rules3
2370 }
2371
2372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version <= 0x190)
2373 {
2374 4 set_qr(qr_MEANPLACEDTRAPS,0);
2375 4 }
2376 }
2377
2378
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2379 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2380 {
2381 4 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2382 4 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2383 4 set_qr(qr_BRKBLSHLDS_DEP,1);
2384 4 }
2385
2386
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2387 {
2388 byte *mf=temp_midi_flags;
2389
2390 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2391 {
2392 mf=(byte*)dummybuf;
2393 }
2394
2395 if(!pfread(mf,32,f)) // read new header additions
2396 {
2397 return qe_invalid; // starting at foo2
2398 }
2399
2400 if(!pfread(dummybuf,18,f)) // read new header additions
2401 {
2402 return qe_invalid; // starting at foo2
2403 }
2404 }
2405
2406
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2407 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2408 {
2409 4 memset(tempheader.templatepath,0,2048);
2410 4 }
2411 else
2412 {
2413 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2414 {
2415 return qe_invalid;
2416 }
2417 }
2418
2419
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2420 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2421 {
2422 4 tempheader.use_keyfile=0;
2423 4 }
2424 4 }
2425 else
2426 {
2427 //section id
2428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(!p_mgetl(&dummy,f))
2429 {
2430 return qe_invalid;
2431 }
2432
2433 //section version info
2434
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&version,f))
2435 {
2436 return qe_invalid;
2437 }
2438
2439 126 FFCore.quest_format[vHeader] = version;
2440
2441
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&dummy,f))
2442 {
2443 return qe_invalid;
2444 }
2445
2446 //section size
2447
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy,f))
2448 {
2449 return qe_invalid;
2450 }
2451
2452 //finally... section data
2453
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&tempheader.zelda_version,f))
2454 {
2455 return qe_invalid;
2456 }
2457
2458 126 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2459
2460 //do some quick checking...
2461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(tempheader.zelda_version > ZELDA_VERSION)
2462 {
2463 return qe_version;
2464 }
2465
2466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2467 {
2468 return qe_invalid;
2469 }
2470
2471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(bad_version(tempheader.zelda_version))
2472 {
2473 return qe_obsolete;
2474 }
2475
2476
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_getc(&tempheader.build,f))
2477 {
2478 return qe_invalid;
2479 }
2480
2481 126 FFCore.quest_format[vBuild] = tempheader.build;
2482
2483
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 114 times.
126 if(version<3)
2484 {
2485
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!pfread(temp_pwd,30,f))
2486 {
2487 return qe_invalid;
2488 }
2489
2490
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_pwdkey,f))
2491 {
2492 return qe_invalid;
2493 }
2494
2495 12 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2496 12 cvs_MD5Init(&ctx);
2497 12 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2498 12 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2499 12 }
2500 else
2501 {
2502
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2503 {
2504 return qe_invalid;
2505 }
2506 }
2507
2508
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&tempheader.internal,f))
2509 {
2510 return qe_invalid;
2511 }
2512
2513
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_getc(&tempheader.quest_number,f))
2514 {
2515 return qe_invalid;
2516 }
2517
2518 126 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2519
2520 126 size_t versz = version < 8 ? 9 : 16;
2521
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!pfread(tempheader.version,versz,f))
2522 {
2523 return qe_invalid;
2524 }
2525
2526 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2527 //needs to be copied as char[9] or stored as a s.str
2528
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!pfread(tempheader.minver,versz,f))
2529 {
2530 return qe_invalid;
2531 }
2532
2533 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2534
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2535 {
2536 return qe_invalid;
2537 }
2538 126 tempheader.title[sizeof(tempheader.title)-1] = 0;
2539
2540
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2541 {
2542 return qe_invalid;
2543 }
2544 126 tempheader.author[sizeof(tempheader.author)-1] = 0;
2545
2546
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_getc(&tempheader.use_keyfile,f))
2547 {
2548 return qe_invalid;
2549 }
2550
2551 /*
2552 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2553 {
2554 return qe_invalid;
2555 }
2556 */
2557
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2558 {
2559 return qe_invalid;
2560 }
2561
2562
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!pfread(&dummybuf,4,f))
2563 {
2564 return qe_invalid;
2565 }
2566
2567
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2568 {
2569 return qe_invalid;
2570 }
2571
2572
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!pfread(dummybuf,14,f))
2573 {
2574 return qe_invalid;
2575 }
2576
2577 126 templatepath_len=sizeof(tempheader.templatepath);
2578
2579
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
126 if(version==1)
2580 {
2581 12 templatepath_len=280;
2582 12 }
2583
2584
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!pfread(tempheader.templatepath,templatepath_len,f))
2585 {
2586 return qe_invalid;
2587 }
2588
2589
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_getc(&temp_map_count,f))
2590 {
2591 return qe_invalid;
2592 }
2593
2594
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if(version>=4)
2595 {
2596
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.new_version_id_main,f))
2597 {
2598 return qe_invalid;
2599 }
2600
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.new_version_id_second,f))
2601 {
2602 return qe_invalid;
2603 }
2604
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.new_version_id_third,f))
2605 {
2606 return qe_invalid;
2607 }
2608
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2609 {
2610 return qe_invalid;
2611 }
2612
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2613 {
2614 return qe_invalid;
2615 }
2616
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.new_version_id_beta,f))
2617 {
2618 return qe_invalid;
2619 }
2620
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2621 {
2622 return qe_invalid;
2623 }
2624
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.new_version_id_release,f))
2625 {
2626 return qe_invalid;
2627 }
2628
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2629 {
2630 return qe_invalid;
2631 }
2632
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&tempheader.new_version_id_date_month,f))
2633 {
2634 return qe_invalid;
2635 }
2636
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&tempheader.new_version_id_date_day,f))
2637 {
2638 return qe_invalid;
2639 }
2640
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2641 {
2642 return qe_invalid;
2643 }
2644
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2645 {
2646 return qe_invalid;
2647 }
2648
2649
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!pfread(tempheader.new_version_devsig,256,f))
2650 {
2651 return qe_invalid;
2652 }
2653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2654 strcpy(tempheader.new_version_devsig, "EmilyV99");
2655
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!pfread(tempheader.new_version_compilername,256,f))
2656 {
2657 return qe_invalid;
2658 }
2659
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!pfread(tempheader.new_version_compilerversion,256,f))
2660 {
2661 return qe_invalid;
2662 }
2663
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!pfread(tempheader.product_name,1024,f))
2664 {
2665 return qe_invalid;
2666 }
2667
2668
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&tempheader.compilerid,f))
2669 {
2670 return qe_invalid;
2671 }
2672
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2673 {
2674 return qe_invalid;
2675 }
2676
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2677 {
2678 return qe_invalid;
2679 }
2680
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2681 {
2682 return qe_invalid;
2683 }
2684
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2685 {
2686 return qe_invalid;
2687 }
2688
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetw(&tempheader.developerid,f))
2689 {
2690 return qe_invalid;
2691 }
2692
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!pfread(tempheader.made_in_module_name,1024,f))
2693 {
2694 return qe_invalid;
2695 }
2696
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!pfread(tempheader.build_datestamp,256,f))
2697 {
2698 return qe_invalid;
2699 }
2700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(!pfread(tempheader.build_timestamp,256,f))
2701 {
2702 return qe_invalid;
2703 }
2704 37 }
2705 else // <4
2706 {
2707 89 tempheader.new_version_id_main = 0;
2708 89 tempheader.new_version_id_second = 0;
2709 89 tempheader.new_version_id_third = 0;
2710 89 tempheader.new_version_id_fourth = 0;
2711 89 tempheader.new_version_id_alpha = 0;
2712 89 tempheader.new_version_id_beta = 0;
2713 89 tempheader.new_version_id_gamma = 0;
2714 89 tempheader.new_version_id_release = 0;
2715 89 tempheader.new_version_id_date_year = 0;
2716 89 tempheader.new_version_id_date_month = 0;
2717 89 tempheader.new_version_id_date_day = 0;
2718 89 tempheader.new_version_id_date_hour = 0;
2719 89 tempheader.new_version_id_date_minute = 0;
2720
2721 89 memset(tempheader.new_version_devsig, 0, 256);
2722 89 memset(tempheader.new_version_compilername, 0, 256);
2723 89 memset(tempheader.new_version_compilerversion, 0, 256);
2724 89 memset(tempheader.product_name, 0, 1024);
2725 89 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2726
2727 89 tempheader.compilerid = 0;
2728 89 tempheader.compilerversionnumber_first = 0;
2729 89 tempheader.compilerversionnumber_second = 0;
2730 89 tempheader.compilerversionnumber_third = 0;
2731 89 tempheader.compilerversionnumber_fourth = 0;
2732 89 tempheader.developerid = 0;
2733
2734 89 memset(tempheader.made_in_module_name, 0, 1024);
2735 89 memset(tempheader.build_datestamp, 0, 256);
2736 89 memset(tempheader.build_timestamp, 0, 256);
2737 }
2738
2739
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if ( version >= 5 )
2740 {
2741
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!pfread(tempheader.build_timezone,6,f))
2742 {
2743 return qe_invalid;
2744 }
2745 37 }
2746 else // < 5
2747 {
2748 89 memset(tempheader.build_timezone, 0, 6);
2749 }
2750
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 37 times.
126 if ( version >= 6 )
2751 {
2752 byte b;
2753
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&b,f))
2754 {
2755 return qe_invalid;
2756 }
2757 37 tempheader.external_zinfo = b?true:false;
2758 37 read_zinfo = true;
2759 37 }
2760
2761
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if(version >= 7)
2762 {
2763
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2764 {
2765 return qe_invalid;
2766 }
2767 37 }
2768 else
2769 {
2770 89 tempheader.new_version_is_nightly = false;
2771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(tempheader.zelda_version < 0x255)
2772 {
2773
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
89 switch(tempheader.zelda_version)
2774 {
2775 case 0x254:
2776 tempheader.new_version_id_main = 2;
2777 tempheader.new_version_id_second = 54;
2778 break;
2779 case 0x250:
2780
6/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 10 times.
✓ Branch 15 taken 1 times.
77 switch(tempheader.build)
2781 {
2782 case 19:
2783 tempheader.new_version_id_main = 2;
2784 tempheader.new_version_id_second = 50;
2785 tempheader.new_version_id_gamma = 1;
2786 break;
2787 case 20:
2788 tempheader.new_version_id_main = 2;
2789 tempheader.new_version_id_second = 50;
2790 tempheader.new_version_id_gamma = 2;
2791 break;
2792 case 21:
2793 tempheader.new_version_id_main = 2;
2794 tempheader.new_version_id_second = 50;
2795 tempheader.new_version_id_gamma = 3;
2796 break;
2797 case 22:
2798 tempheader.new_version_id_main = 2;
2799 tempheader.new_version_id_second = 50;
2800 tempheader.new_version_id_gamma = 4;
2801 break;
2802 case 23:
2803 tempheader.new_version_id_main = 2;
2804 tempheader.new_version_id_second = 50;
2805 tempheader.new_version_id_gamma = 5;
2806 break;
2807 case 24:
2808 22 tempheader.new_version_id_main = 2;
2809 22 tempheader.new_version_id_second = 50;
2810 22 tempheader.new_version_id_release = -1;
2811 22 break;
2812 case 25:
2813 tempheader.new_version_id_main = 2;
2814 tempheader.new_version_id_second = 50;
2815 tempheader.new_version_id_third = 1;
2816 tempheader.new_version_id_gamma = 1;
2817 break;
2818 case 26:
2819 tempheader.new_version_id_main = 2;
2820 tempheader.new_version_id_second = 50;
2821 tempheader.new_version_id_third = 1;
2822 tempheader.new_version_id_gamma = 2;
2823 break;
2824 case 27:
2825 tempheader.new_version_id_main = 2;
2826 tempheader.new_version_id_second = 50;
2827 tempheader.new_version_id_third = 1;
2828 tempheader.new_version_id_gamma = 3;
2829 break;
2830 case 28:
2831 5 tempheader.new_version_id_main = 2;
2832 5 tempheader.new_version_id_second = 50;
2833 5 tempheader.new_version_id_third = 1;
2834 5 tempheader.new_version_id_release = -1;
2835 5 break;
2836 case 29:
2837 24 tempheader.new_version_id_main = 2;
2838 24 tempheader.new_version_id_second = 50;
2839 24 tempheader.new_version_id_third = 2;
2840 24 tempheader.new_version_id_release = -1;
2841 24 break;
2842 case 30:
2843 tempheader.new_version_id_main = 2;
2844 tempheader.new_version_id_second = 50;
2845 tempheader.new_version_id_third = 3;
2846 tempheader.new_version_id_gamma = 1;
2847 break;
2848 case 31:
2849 15 tempheader.new_version_id_main = 2;
2850 15 tempheader.new_version_id_second = 53;
2851 15 tempheader.new_version_id_gamma = -1;
2852 15 break;
2853 case 32:
2854 10 tempheader.new_version_id_main = 2;
2855 10 tempheader.new_version_id_second = 53;
2856 10 tempheader.new_version_id_release = -1;
2857 10 break;
2858 case 33:
2859 1 tempheader.new_version_id_main = 2;
2860 1 tempheader.new_version_id_second = 53;
2861 1 tempheader.new_version_id_third = 1;
2862 1 break;
2863 }
2864 77 break;
2865
2866 case 0x211:
2867 tempheader.new_version_id_main = 2;
2868 tempheader.new_version_id_second = 11;
2869 tempheader.new_version_id_beta = tempheader.build;
2870 break;
2871 case 0x210:
2872 12 tempheader.new_version_id_main = 2;
2873 12 tempheader.new_version_id_second = 10;
2874 12 tempheader.new_version_id_beta = tempheader.build;
2875 12 break;
2876 }
2877 89 }
2878 }
2879
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 if(printmetadata || __isZQuest)
2880 {
2881 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2882 }
2883 }
2884
2885 //{ Version Warning
2886 130 int32_t vercmp = tempheader.compareVer();
2887 130 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2888 130 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2889
4/6
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
167 if(vercmp > 0 || (!vercmp &&
2890
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 (astatecmp > 0 || (!astatecmp &&
2891 37 avercmp > 0))))
2892 {
2893 bool r = true;
2894 if(loadquest_report)
2895 {
2896 enter_sys_pal();
2897 AlertDialog("Quest saved in newer version",
2898 "This quest was last saved in a newer version of ZQuest."
2899 " Attempting to load this quest may not work correctly; to"
2900 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2901 "\n\nWould you like to continue loading anyway? (Not recommended)",
2902 [&](bool ret,bool)
2903 {
2904 r = ret;
2905 }).show();
2906 exit_sys_pal();
2907 }
2908 if(!r)
2909 return qe_silenterr;
2910 }
2911
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 else if(tempheader.compareDate() > 0)
2912 {
2913 bool r = true;
2914 if(loadquest_report)
2915 {
2916 enter_sys_pal();
2917 AlertDialog("Quest saved in newer build",
2918 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2919 " issues loading in this build."
2920 "\n{}"
2921 "\n\nWould you like to continue loading anyway?",
2922 tempheader.getVerCmpStr()),
2923 [&](bool ret,bool)
2924 {
2925 r = ret;
2926 }).show();
2927 exit_sys_pal();
2928 }
2929 if(!r)
2930 return qe_silenterr;
2931 }
2932 //}
2933
2934 130 read_ext_zinfo = tempheader.external_zinfo;
2935
2936 130 memcpy(Header, &tempheader, sizeof(tempheader));
2937 130 map_count=temp_map_count;
2938 130 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2939
2940 130 return 0;
2941 130 }
2942
2943 130 int32_t readrules(PACKFILE *f, zquestheader *Header)
2944 {
2945 int32_t dummy;
2946 zquestheader tempheader;
2947 130 word s_version=0;
2948 130 dword compatrule_version=0;
2949
2950 130 memcpy(&tempheader, Header, sizeof(tempheader));
2951
2952
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(tempheader.zelda_version >= 0x193)
2953 {
2954 //section version info
2955
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_version,f))
2956 {
2957 return qe_invalid;
2958 }
2959
2960 126 FFCore.quest_format[vRules] = s_version;
2961
2962
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&dummy,f))
2963 {
2964 return qe_invalid;
2965 }
2966
2967
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 37 times.
126 if(s_version > 16)
2968 {
2969
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&compatrule_version,f))
2970 {
2971 return qe_invalid;
2972 }
2973 37 }
2974 126 FFCore.quest_format[vCompatRule] = compatrule_version;
2975
2976 //section size
2977
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy,f))
2978 {
2979 return qe_invalid;
2980 }
2981
2982
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 37 times.
126 if ( s_version < 15 )
2983 {
2984 //finally... section data
2985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2986 {
2987 return qe_invalid;
2988 }
2989 89 }
2990 else
2991 {
2992
2993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2994 {
2995 return qe_invalid;
2996 }
2997
2998 }
2999 126 }
3000
3001 //al_trace("Rules version %d\n", s_version);
3002 //{ bunch of compat stuff
3003 130 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
3004
3005
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<2)
3006 {
3007 16 set_qr(14,0);
3008 16 set_qr(27,0);
3009 16 set_qr(28,0);
3010 16 set_qr(29,0);
3011 16 set_qr(30,0);
3012 16 set_qr(32,0);
3013 16 set_qr(36,0);
3014 16 set_qr(49,0);
3015 16 set_qr(50,0);
3016 16 set_qr(51,0);
3017 16 set_qr(68,0);
3018 16 set_qr(75,0);
3019 16 set_qr(76,0);
3020 16 set_qr(98,0);
3021 16 set_qr(110,0);
3022 16 set_qr(113,0);
3023 16 set_qr(116,0);
3024 16 set_qr(102,0);
3025 16 set_qr(132,0);
3026 16 }
3027
3028 //Now, do any updates...
3029
3/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3030 {
3031 16 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
3032 16 set_qr(qr_REPLACEOPENDOORS, 1);
3033 16 set_qr(qr_OLDLENSORDER, 1);
3034 16 set_qr(qr_NOFAIRYGUYFIRES, 1);
3035 16 set_qr(qr_TRIGGERSREPEAT, 1);
3036 16 }
3037
3038
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3039 {
3040 4 set_qr(qr_WALLFLIERS,1);
3041 4 }
3042
3043
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3044 {
3045 4 set_qr(qr_NOBOMBPALFLASH,1);
3046 4 }
3047
3048
5/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
130 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3049 {
3050 6 set_qr(qr_NOSCROLLCONTINUE,1);
3051 6 }
3052
3053
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
132 if(tempheader.zelda_version <= 0x210)
3054 {
3055 16 set_qr(qr_ARROWCLIP,1);
3056 16 }
3057
3058
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 12 times.
128 if(tempheader.zelda_version == 0x210)
3059 {
3060 12 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
3061 12 set_qr(qr_CMBCYCLELAYERS, 0);
3062 12 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
3063 12 }
3064
3065
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(tempheader.zelda_version <= 0x210)
3066 {
3067 16 set_qr(qr_OLDSTYLEWARP,1);
3068 16 set_qr(qr_210_WARPRETURN,1);
3069 16 }
3070
3071 //might not be correct
3072
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(tempheader.zelda_version < 0x210)
3073 {
3074 4 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3075 4 set_qr(qr_OLDTRIBBLES_DEP,1);
3076 4 set_qr(qr_OLDHOOKSHOTGRAB,1);
3077 4 }
3078
3079
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(tempheader.zelda_version < 0x211)
3080 {
3081 16 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
3082 16 }
3083
3084
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
128 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3085 {
3086 set_qr(qr_192b163_WARP,1);
3087 }
3088
3089
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 12 times.
128 if(tempheader.zelda_version == 0x210)
3090 {
3091 12 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3092 12 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3093 12 set_qr(qr_DMGCOMBOPRI, 0);
3094 12 }
3095
3096
5/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
128 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3097 {
3098 16 set_qr(qr_OLDPICKUP,1);
3099 16 }
3100
3101
5/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
132 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3102 {
3103 16 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
3104 16 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3105 16 }
3106
3107
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
132 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3108 {
3109 16 set_qr(qr_HOOKSHOTDOWNBUG, 1);
3110 16 }
3111
3112
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 22 times.
128 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3113 {
3114 22 set_qr(qr_PEAHATCLOCKVULN, 1);
3115 22 }
3116
3117
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 75 times.
128 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3118 {
3119 16 set_qr(qr_OLD_DOORREPAIR, 1);
3120 16 }
3121
3122
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 79 times.
128 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3123 {
3124 16 set_qr(qr_OLD_SECRETMONEY, 1);
3125 16 }
3126
3127
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 57 times.
132 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3128 {
3129 38 set_qr(qr_OLD_POTION_OR_HC, 1);
3130 38 }
3131
3132
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 57 times.
132 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3133 {
3134 38 set_qr(qr_OFFSCREENWEAPONS, 1);
3135 38 }
3136
3137 //Bombchu fix.
3138
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 77 times.
132 if(tempheader.zelda_version == 0x250)
3139 {
3140
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 22 times.
77 if ( tempheader.build == 24 ) //2.50.0
3141 {
3142 22 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3143 22 }
3144
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 5 times.
77 if ( tempheader.build == 28 ) //2.50.1
3145 {
3146 5 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3147 5 }
3148
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
77 if ( tempheader.build == 29 ) //2.50.2
3149 {
3150 24 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3151 24 }
3152
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if ( tempheader.build == 30 ) //2.50.3RC1
3153 {
3154 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3155 }
3156 77 }
3157
3158
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 52 times.
132 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3159 {
3160 // qr_OFFSETEWPNCOLLISIONFIX
3161 // All 'official' quests need this disabled.
3162 // All 2.10 and lower quests need this enabled to preseve compatability.
3163 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3164
3165 //~Gleeok
3166 43 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3167
3168 // Broke in build 695
3169
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
43 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3170 27 set_qr(qr_BROKENSTATUES, 1);
3171 43 }
3172
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 if (tempheader.zelda_version <= 0x190)
3173 {
3174 4 set_qr(qr_COPIED_SWIM_SPRITES, 1);
3175 4 }
3176
9/10
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 38 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 37 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 37 times.
132 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3177 {
3178 94 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
3179 94 }
3180
3181
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3182 {
3183 16 set_qr(qr_OLD_210_WATER, 1);
3184 16 }
3185
3186
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3187 {
3188 93 set_qr(qr_STEP_IS_FLOAT,0);
3189 93 }
3190
3191
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if ( tempheader.zelda_version < 0x250 )
3192 {
3193 16 set_qr(qr_8WAY_SHOT_SFX, 1);
3194 16 }
3195
3196
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version < 3)
3197 {
3198 16 set_qr(qr_HOLDNOSTOPMUSIC, 1);
3199 16 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
3200 16 }
3201
3202
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<4)
3203 {
3204 16 set_qr(10,0);
3205 16 }
3206
3207
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<5)
3208 {
3209 16 set_qr(27,0);
3210 16 }
3211
3212
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<6)
3213 {
3214 16 set_qr(46,0);
3215 16 }
3216
3217
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<7) // January 2008
3218 {
3219 16 set_qr(qr_HEARTSREQUIREDFIX,0);
3220 16 set_qr(qr_PUSHBLOCKCSETFIX,1);
3221 16 }
3222
3223
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 114 times.
130 if(s_version<8)
3224 {
3225 16 set_qr(12, 0);
3226 16 }
3227 else
3228 {
3229 114 set_bit(deprecated_rules, 12, 0);
3230 }
3231
3232
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<9) // October 2008
3233 {
3234 16 set_qr(qr_NOROPE2FLASH_DEP,0);
3235 16 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3236 16 set_qr(qr_GHINI2BLINK_DEP,0);
3237 16 set_qr(qr_PHANTOMGHINI2_DEP,0);
3238 16 }
3239
3240
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<10) // December 2008
3241 {
3242 16 set_qr(qr_NOCLOCKS_DEP,0);
3243 16 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3244 16 }
3245
3246
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<11) // April 2009
3247 {
3248 16 set_qr(qr_SLOWENEMYANIM_DEP,0);
3249 16 }
3250
3251 // This served no purpose.
3252 // if(s_version<12) // December 2009
3253 // {
3254 // set_qr(qr_BRKBLSHLDS_DEP,0);
3255 // set_qr(qr_OLDTRIBBLES_DEP,0);
3256 // }
3257
3258 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3259
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version < 13)
3260 {
3261 16 set_qr(qr_SHOPCHEAT, 1);
3262 16 }
3263
3264 // Not entirely sure this is the best place for this...
3265 //2.50.2 bitmap offset fix
3266 130 memset(extra_rules, 0, EXTRARULES_SIZE);
3267
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 50 times.
130 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3268 {
3269 43 set_er(er_BITMAPOFFSET, 1);
3270 43 set_qr(qr_BITMAPOFFSETFIX, 1);
3271 43 }
3272 //required because quest templates also used this bit, although
3273 //it never did anything, before. -Z
3274
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 77 times.
130 if ( tempheader.zelda_version == 0x250 )
3275 {
3276
5/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 38 times.
77 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3277 {
3278 39 set_er(er_BITMAPOFFSET, 0);
3279 39 set_qr(qr_BITMAPOFFSETFIX, 0);
3280 39 }
3281 77 }
3282
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if ( tempheader.zelda_version == 0x254 )
3283 {
3284 set_er(er_BITMAPOFFSET, 0);
3285 set_qr(qr_BITMAPOFFSETFIX, 0);
3286 }
3287
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
130 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3288 {
3289 set_er(er_BITMAPOFFSET, 0);
3290 set_qr(qr_BITMAPOFFSETFIX, 0);
3291 }
3292 //optimise fast drawing for older versions.
3293
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3294 {
3295 93 set_qr(qr_OLDSPRITEDRAWS, 1);
3296 93 }
3297 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3298 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3299 //older quests can set the rule by hand. We need a new qst.dat again.
3300
4/6
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3301 {
3302 set_qr(qr_OLDEWPNPARENT, 1);
3303 }
3304
4/6
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3305 {
3306 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3307 }
3308
4/6
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3309 {
3310 set_qr(qr_OLDQUESTMISC, 1);
3311 }
3312
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if ( tempheader.zelda_version < 0x254 )
3313 {
3314 93 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3315 93 set_qr(qr_OLDEWPNPARENT, 0);
3316 93 set_qr(qr_OLDQUESTMISC, 0);
3317 93 }
3318
3319 //item scripts continue to run
3320
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3321 {
3322 93 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3323 93 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3324 93 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3325 93 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3326 93 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3327 93 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3328 93 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3329 93 }
3330
3331
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3332 {
3333 93 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3334 93 }
3335
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3336 {
3337 93 set_qr(qr_TRACESCRIPTIDS, 0);
3338 93 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3339 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3340 93 set_qr(qr_PARSER_250DIVISION,1);
3341 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3342 93 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3343 93 set_qr(qr_PARSER_FORCE_INLINE,0);
3344 93 set_qr(qr_PARSER_BINARY_32BIT,0);
3345
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 2 times.
93 if ( get_qr(qr_SELECTAWPN) )
3346 {
3347 2 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3348 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3349 //Now they **do**, unless you disable that behaviour.
3350 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3351 //now enable the disable L/R item swap on load.
3352 2 }
3353
3354 93 }
3355
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3356 {
3357 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3358 93 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3359 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3360 //animations ending earlier than they should.
3361 93 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3362 //Enemies would ignore solidity on the top half of combos
3363 93 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3364 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3365 93 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3366 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3367 93 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3368 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3369 93 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3370 93 }
3371
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if ( tempheader.zelda_version < 0x255 )
3372 {
3373 93 set_qr(qr_NOFFCWAITDRAW, 1);
3374 93 set_qr(qr_NOITEMWAITDRAW, 1);
3375 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3376 93 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3377 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3378 93 }
3379
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3380 {
3381 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3382 93 }
3383
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3384 {
3385 93 set_qr(qr_OLD_PRINTF_ARGS, 1);
3386 93 }
3387
3388
3389
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3390 {
3391 93 set_qr(qr_BROKEN_RING_POWER, 1);
3392 93 }
3393
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3394 {
3395 93 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3396 93 }
3397
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3398 {
3399 93 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3400 93 }
3401
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3402 {
3403 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3404
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(get_qr(qr_SET_XBUTTON_ITEMS))
3405 set_qr(qr_SET_YBUTTON_ITEMS,1);
3406 93 }
3407
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3408 {
3409 93 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3410 93 }
3411
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3412 {
3413 93 set_qr(qr_OLD_CHEST_COLLISION,1);
3414 93 }
3415
3416
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if ( tempheader.zelda_version < 0x254 )
3417 {
3418 93 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3419 93 }
3420 //Sideview spikes in 2.50.0
3421
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 55 times.
130 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3422 {
3423 38 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3424 38 }
3425 //more 2.50 fixes -Z
3426
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 26 times.
130 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3427 {
3428 67 set_qr(qr_MELEEMAGICCOST, 0);
3429 67 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3430 67 set_qr(qr_OLDMIRRORCOMBOS, 1);
3431 67 set_qr(qr_BROKENBOOKCOST, 1);
3432 67 set_qr(qr_BROKENCHARINTDRAWING, 1);
3433
3434 67 }
3435
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
130 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3436 {
3437 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3438 set_qr(qr_MELEEMAGICCOST, 1);
3439 }
3440
3441
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(tempheader.zelda_version < 0x193)
3442 {
3443 4 set_qr(qr_SHORTDGNWALK, 1);
3444 4 }
3445
3446
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(tempheader.zelda_version < 0x255)
3447 {
3448 93 set_qr(qr_OLDINFMAGIC, 1);
3449 93 }
3450
3451
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3452 {
3453 16 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3454 16 }
3455
3456
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3457 {
3458 93 set_qr(qr_OLD_F6,1);
3459 93 }
3460
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3461 {
3462 93 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3463 93 }
3464
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3465 {
3466 93 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3467 93 }
3468
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3469 {
3470 93 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3471 93 }
3472 //}
3473
3474
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3475 93 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3476
3477
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 2) //Old CSet2 Handling
3478 93 set_qr(qr_OLDCS2,1);
3479
3480
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3481 93 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3482
3483
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3484 93 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3485
3486
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 77 times.
130 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3487 77 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3488
3489
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3490 93 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3491
3492
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3493 93 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3494
3495
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3496 93 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3497
3498
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 9)
3499 {
3500 //Hardcoded BS Patras
3501 93 set_qr(qr_HARDCODED_BS_PATRA,1);
3502 //Hardcoded Patra Inner Eye offsets
3503 93 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3504 //Broken 'Big enemy' animation style
3505 93 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3506 //Broken Attribute 31/32
3507 93 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3508 93 }
3509
3510
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 10) //Shared candle use limits
3511 93 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3512
3513
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 11) //No cross-screen return points
3514 93 set_qr(qr_OLD_RESPAWN_POINTS,1);
3515
3516
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 12)
3517 {
3518 //Old fire trail duration
3519 93 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3520 //Old Intro String in Ganon Room Behavior
3521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3522 93 else set_qr(qr_GANONINTRO,1);
3523 93 }
3524
3525
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
130 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3526 set_qr(qr_ANONE_NOANIM,1);
3527
3528
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 14) //Old Bridge Combo Behavior
3529 93 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3530
3531
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 15) //Broken Z3 Animation
3532 93 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3533
3534
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3535 93 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3536
3537
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 17)
3538 {
3539 //Old Quake/DrawYOffset behavior
3540 //set_qr(qr_OLD_DRAWOFFSET,1);
3541 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3542 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3543 93 }
3544
3545
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 18)
3546 {
3547 //Broken DrawScreen Derivative Functions
3548 93 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3549 //Scrolling Cancels Charge
3550 93 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3551 93 }
3552
3553
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3554 93 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3555
3556
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 20)
3557 93 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3558
3559
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 21)
3560 {
3561 93 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3562 93 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3563 93 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3564 93 set_qr(qr_OLD_BUG_NET,1);
3565 93 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3566 93 }
3567
3568
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 22)
3569 93 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3570
3571
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 23)
3572 93 set_qr(qr_OLD_HALF_MAGIC,1);
3573
3574
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 24)
3575 {
3576 93 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3577 93 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3578 93 }
3579
3580
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 25)
3581 {
3582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3583 93 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3584 93 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3585 93 }
3586
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 26)
3587 {
3588 93 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3589 93 set_qr(qr_POLVIRE_NO_SHADOW,1);
3590 93 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3591 93 }
3592
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3593 {
3594
2/2
✓ Branch 0 taken 27993 times.
✓ Branch 1 taken 93 times.
28086 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3595 27993 set_qr(q,0);
3596
2/2
✓ Branch 0 taken 10416 times.
✓ Branch 1 taken 93 times.
10509 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3597 10416 set_qr(q,0);
3598 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3599 93 }
3600
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(compatrule_version < 28)
3601 95 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3602
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(compatrule_version < 29)
3603 95 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3604
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(compatrule_version < 30)
3605 {
3606 95 set_qr(qr_DECO_2_YOFFSET,1);
3607 95 set_qr(qr_SCREENSTATE_80s_BUG,1);
3608 95 }
3609
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(compatrule_version < 31)
3610 {
3611 95 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3612 95 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3613 95 }
3614
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(compatrule_version < 32)
3615 95 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3616
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(compatrule_version < 33)
3617 95 set_qr(qr_NO_LIFT_SPRITE,1);
3618
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(compatrule_version < 34)
3619 {
3620 95 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3621 95 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3622 95 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3623 95 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3624 95 }
3625
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 96 times.
130 if(compatrule_version < 35)
3626 {
3627 96 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3628 96 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3629 96 }
3630
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 96 times.
130 if(compatrule_version < 36)
3631 96 set_qr(qr_OLD_SHALLOW_SFX,1);
3632
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 98 times.
130 if(compatrule_version < 37)
3633 98 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3634
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 98 times.
130 if(compatrule_version < 38)
3635 98 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3636
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 98 times.
130 if(compatrule_version < 39)
3637 98 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3638
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 98 times.
130 if(compatrule_version < 40)
3639 98 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3640
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 99 times.
130 if(compatrule_version < 41)
3641 99 set_qr(qr_BROKENHITBY,1);
3642
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 99 times.
130 if(compatrule_version < 42)
3643 99 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3644
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 99 times.
130 if(compatrule_version < 43)
3645 99 set_qr(qr_OLD_BOMB_HITBOXES,1);
3646
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 99 times.
130 if(compatrule_version < 44)
3647 99 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3648
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 99 times.
130 if(compatrule_version < 45)
3649 99 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3650
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 99 times.
130 if(compatrule_version < 46)
3651 99 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3652
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 102 times.
130 if(compatrule_version < 47)
3653 {
3654 102 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3655 102 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3656 102 }
3657
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 102 times.
130 if(compatrule_version < 48)
3658 102 set_qr(qr_OLD_GUY_HANDLING,1);
3659
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 102 times.
130 if(compatrule_version < 49)
3660 102 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3661
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 102 times.
130 if(compatrule_version < 50)
3662 102 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3663
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 102 times.
130 if(compatrule_version < 51)
3664 102 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3665
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 102 times.
130 if (compatrule_version < 52)
3666 102 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3667
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 102 times.
130 if(compatrule_version < 53)
3668 {
3669 102 set_qr(qr_OLD_SUBSCR,1);
3670 102 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3671 102 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3672 102 }
3673
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 122 times.
130 if(compatrule_version < 54)
3674 122 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3675
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 122 times.
130 if(compatrule_version < 55)
3676 122 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3677
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 122 times.
130 if(compatrule_version < 56)
3678 122 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(compatrule_version < 57)
3680 130 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3681
3682 130 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3683
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if (s_version < 16)
3684 93 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3685
3686 130 memcpy(Header, &tempheader, sizeof(tempheader));
3687
3688 130 return 0;
3689 130 }
3690
3691 1092635 void init_msgstr(MsgStr *str)
3692 {
3693 1092635 str->s = "";
3694 1092635 str->s.shrink_to_fit();
3695 1092635 str->nextstring=0;
3696 1092635 str->tile=0;
3697 1092635 str->cset=0;
3698 1092635 str->trans=false;
3699 1092635 str->font=font_zfont;
3700 1092635 str->y=32;
3701 1092635 str->sfx=18;
3702 1092635 str->listpos=0;
3703 1092635 str->x=24;
3704 1092635 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3705 1092635 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3706 1092635 str->hspace=0;
3707 1092635 str->vspace=0;
3708 1092635 str->stringflags=0;
3709 1092635 str->margins[up] = 8;
3710 1092635 str->margins[down] = 0;
3711 1092635 str->margins[left] = 8;
3712 1092635 str->margins[right] = 0;
3713 1092635 str->portrait_tile = 0;
3714 1092635 str->portrait_cset = 0;
3715 1092635 str->portrait_x = 0;
3716 1092635 str->portrait_y = 0;
3717 1092635 str->portrait_tw = 1;
3718 1092635 str->portrait_th = 1;
3719 1092635 str->shadow_type = 0;
3720 1092635 str->shadow_color = 0;
3721 1092635 str->drawlayer = 6;
3722 1092635 }
3723
3724 130 void init_msgstrings(int32_t start, int32_t end)
3725 {
3726
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 130 times.
130 if(end <= start || end-start > msg_strings_size)
3727 return;
3728
3729
2/2
✓ Branch 0 taken 1064960 times.
✓ Branch 1 taken 130 times.
1065090 for(int32_t i=start; i<end; i++)
3730 {
3731 1064960 init_msgstr(&MsgStrings[i]);
3732 1064960 MsgStrings[i].listpos=i;
3733 1064960 }
3734
3735
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(start==0)
3736 {
3737 130 MsgStrings[0].s = "(None)";
3738 130 MsgStrings[0].listpos = 0;
3739 130 }
3740 130 }
3741
3742 130 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3743 {
3744 130 MsgStr tempMsgString;
3745
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 init_msgstr(&tempMsgString);
3746
3747 130 word temp_msg_count=0;
3748 word temp_expansion[16];
3749 130 memset(temp_expansion, 0, 16*sizeof(word));
3750 130 char buf[8193] = {0};
3751
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version < 0x193)
3752 {
3753 byte tempbyte;
3754 4 int32_t strings_to_read=0;
3755
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3756
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
3757 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3758 {
3759 4 strings_to_read=128;
3760 4 temp_msg_count=Header->old_str_count;
3761
3762 // Some sort of string count corruption seems to be common in old quests
3763
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(temp_msg_count>128)
3764 {
3765 temp_msg_count=128;
3766 }
3767 4 }
3768 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3769 {
3770 strings_to_read=255;
3771 temp_msg_count=Header->old_str_count;
3772 }
3773 else
3774 {
3775 if(!p_igetw(&temp_msg_count,f))
3776 {
3777 return qe_invalid;
3778 }
3779
3780 strings_to_read=temp_msg_count;
3781
3782 if(temp_msg_count >= msg_strings_size)
3783 {
3784 Z_message("Reallocating string buffer...\n");
3785
3786 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3787 // return qe_nomem;
3788
3789 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3790 delete[] MsgStrings;
3791 MsgStrings = new MsgStr[MAXMSGS];
3792 msg_strings_size = MAXMSGS;
3793 for(auto q = 0; q < msg_strings_size; ++q)
3794 {
3795 MsgStrings[q].clear();
3796 }
3797 }
3798 }
3799
3800 //reset the message strings
3801
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 init_msgstrings(0,msg_strings_size);
3802
3803
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t x=0; x<strings_to_read; x++)
3804 {
3805
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 init_msgstr(&tempMsgString);
3806 512 tempMsgString.listpos = x;
3807
3808
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!pfread(buf,73,f))
3809 {
3810 return qe_invalid;
3811 }
3812
3813 512 buf[74] = '\0';
3814
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 tempMsgString.s = buf;
3815
3816
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3817 {
3818 return qe_invalid;
3819 }
3820
3821
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
512 if((Header->zelda_version < 0x192)||
3822 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3823 {
3824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 tempMsgString.nextstring=tempbyte?x+1:0;
3825
3826
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3827 {
3828 return qe_invalid;
3829 }
3830
3831
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3832 {
3833 return qe_invalid;
3834 }
3835 512 }
3836 else
3837 {
3838 if(!p_igetw(&tempMsgString.nextstring,f))
3839 {
3840 return qe_invalid;
3841 }
3842
3843 if(!pfread(temp_expansion,32,f))
3844 {
3845 return qe_invalid;
3846 }
3847 }
3848
3849
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 MsgStrings[x] = tempMsgString;
3850 512 }
3851 4 }
3852 else
3853 {
3854 int32_t dummy_int;
3855 word s_version;
3856 word s_cversion;
3857
3858 //section version info
3859
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&s_version,f))
3860 {
3861 return qe_invalid;
3862 }
3863
3864 126 FFCore.quest_format[vStrings] = s_version;
3865
3866
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&s_cversion,f))
3867 {
3868 return qe_invalid;
3869 }
3870
3871 //al_trace("Strings version %d\n", s_version);
3872 //section size
3873
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetl(&dummy_int,f))
3874 {
3875 return qe_invalid;
3876 }
3877
3878 //finally... section data
3879
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&temp_msg_count,f))
3880 {
3881 return qe_invalid;
3882 }
3883
3884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(temp_msg_count >= msg_strings_size)
3885 {
3886 Z_message("Reallocating string buffer...\n");
3887
3888 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3889 // return qe_nomem;
3890 delete[] MsgStrings;
3891 MsgStrings = new MsgStr[MAXMSGS];
3892 msg_strings_size = MAXMSGS;
3893 for(auto q = 0; q < msg_strings_size; ++q)
3894 {
3895 MsgStrings[q].clear();
3896 }
3897 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3898 }
3899
3900 //reset the message strings
3901
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 37 times.
126 if(s_version < 7)
3902
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3903
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 init_msgstrings(0,msg_strings_size);
3904
3905 126 int32_t string_length=(s_version<2)?73:145;
3906
3907
2/2
✓ Branch 0 taken 27033 times.
✓ Branch 1 taken 126 times.
27159 for(int32_t i=0; i<temp_msg_count; i++)
3908 {
3909
1/2
✓ Branch 0 taken 27033 times.
✗ Branch 1 not taken.
27033 init_msgstr(&tempMsgString);
3910 27033 tempMsgString.listpos = i;
3911
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 26139 times.
27033 if(s_version > 8)
3912 {
3913
2/4
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 894 times.
✗ Branch 3 not taken.
894 if(!p_igetl(&string_length,f))
3914 {
3915 return qe_invalid;
3916 }
3917 894 }
3918
3919
2/4
✓ Branch 0 taken 27033 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27033 times.
27033 if (string_length < 0 || string_length > 8193)
3920 {
3921 return qe_invalid;
3922 }
3923
3924
2/2
✓ Branch 0 taken 26895 times.
✓ Branch 1 taken 138 times.
27033 if (string_length > 0)
3925 {
3926
2/4
✓ Branch 0 taken 26895 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26895 times.
✗ Branch 3 not taken.
26895 if (!pfread(buf, string_length, f))
3927 {
3928 return qe_invalid;
3929 }
3930 26895 }
3931 else
3932 {
3933 138 buf[0] = 0;
3934 }
3935
3936
2/4
✓ Branch 0 taken 27033 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27033 times.
✗ Branch 3 not taken.
27033 if(!p_igetw(&tempMsgString.nextstring,f))
3937 {
3938 return qe_invalid;
3939 }
3940
3941
2/2
✓ Branch 0 taken 19101 times.
✓ Branch 1 taken 7932 times.
27033 if(s_version<2)
3942 {
3943 19101 buf[72] = '\0';
3944
1/2
✓ Branch 0 taken 19101 times.
✗ Branch 1 not taken.
19101 tempMsgString.s = buf;
3945 19101 }
3946 else
3947 {
3948 // June 2008: A bug corrupted the last 4 chars of a string.
3949 // Discard these.
3950
1/2
✓ Branch 0 taken 7932 times.
✗ Branch 1 not taken.
7932 if(s_version<3)
3951 {
3952 for(int32_t j=140; j<144; j++)
3953 {
3954 buf[j] = '\0';
3955 }
3956 }
3957
1/2
✓ Branch 0 taken 7932 times.
✗ Branch 1 not taken.
7932 if(string_length > 8192) string_length = 8192;
3958 7932 buf[string_length]='\0'; //Force-terminate
3959
1/2
✓ Branch 0 taken 7932 times.
✗ Branch 1 not taken.
7932 tempMsgString.s = buf;
3960
3961
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 7038 times.
7932 if ( s_version >= 6 )
3962 {
3963
2/4
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 894 times.
✗ Branch 3 not taken.
894 if(!p_igetl(&tempMsgString.tile,f))
3964 {
3965 return qe_invalid;
3966 }
3967 894 }
3968 else
3969 {
3970
2/4
✓ Branch 0 taken 7038 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7038 times.
✗ Branch 3 not taken.
7038 if(!p_igetw(&tempMsgString.tile,f))
3971 {
3972 return qe_invalid;
3973 }
3974 }
3975
3976
2/4
✓ Branch 0 taken 7932 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7932 times.
✗ Branch 3 not taken.
7932 if(!p_getc(&tempMsgString.cset,f))
3977 {
3978 return qe_invalid;
3979 }
3980
3981 byte dummy_char;
3982
3983
2/4
✓ Branch 0 taken 7932 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7932 times.
✗ Branch 3 not taken.
7932 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3984 {
3985 return qe_invalid;
3986 }
3987
3988 7932 tempMsgString.trans=dummy_char!=0;
3989
3990
2/4
✓ Branch 0 taken 7932 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7932 times.
✗ Branch 3 not taken.
7932 if(!p_getc(&tempMsgString.font,f))
3991 {
3992 return qe_invalid;
3993 }
3994
3995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7932 times.
7932 if(s_version < 5)
3996 {
3997 if(!p_getc(&tempMsgString.y,f))
3998 {
3999 return qe_invalid;
4000 }
4001 }
4002 else
4003 {
4004
2/4
✓ Branch 0 taken 7932 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7932 times.
✗ Branch 3 not taken.
7932 if(!p_igetw(&tempMsgString.x,f))
4005 {
4006 return qe_invalid;
4007 }
4008
4009
2/4
✓ Branch 0 taken 7932 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7932 times.
✗ Branch 3 not taken.
7932 if(!p_igetw(&tempMsgString.y,f))
4010 {
4011 return qe_invalid;
4012 }
4013
4014
2/4
✓ Branch 0 taken 7932 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7932 times.
✗ Branch 3 not taken.
7932 if(!p_igetw(&tempMsgString.w,f))
4015 {
4016 return qe_invalid;
4017 }
4018
4019
2/4
✓ Branch 0 taken 7932 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7932 times.
✗ Branch 3 not taken.
7932 if(!p_igetw(&tempMsgString.h,f))
4020 {
4021 return qe_invalid;
4022 }
4023
4024
2/4
✓ Branch 0 taken 7932 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7932 times.
✗ Branch 3 not taken.
7932 if(!p_getc(&tempMsgString.hspace,f))
4025 {
4026 return qe_invalid;
4027 }
4028
4029
2/4
✓ Branch 0 taken 7932 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7932 times.
✗ Branch 3 not taken.
7932 if(!p_getc(&tempMsgString.vspace,f))
4030 {
4031 return qe_invalid;
4032 }
4033
4034
2/4
✓ Branch 0 taken 7932 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7932 times.
✗ Branch 3 not taken.
7932 if(!p_getc(&tempMsgString.stringflags,f))
4035 {
4036 return qe_invalid;
4037 }
4038 }
4039
4040
2/2
✓ Branch 0 taken 7038 times.
✓ Branch 1 taken 894 times.
7932 if(s_version >= 7)
4041 {
4042
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 3576 times.
4470 for(int32_t q = 0; q < 4; ++q)
4043 {
4044
2/4
✓ Branch 0 taken 3576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3576 times.
✗ Branch 3 not taken.
3576 if(!p_getc(&tempMsgString.margins[q],f))
4045 {
4046 return qe_invalid;
4047 }
4048 3576 }
4049
4050
2/4
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 894 times.
✗ Branch 3 not taken.
894 if(!p_igetl(&tempMsgString.portrait_tile,f))
4051 {
4052 return qe_invalid;
4053 }
4054
4055
2/4
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 894 times.
✗ Branch 3 not taken.
894 if(!p_getc(&tempMsgString.portrait_cset,f))
4056 {
4057 return qe_invalid;
4058 }
4059
4060
2/4
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 894 times.
✗ Branch 3 not taken.
894 if(!p_getc(&tempMsgString.portrait_x,f))
4061 {
4062 return qe_invalid;
4063 }
4064
4065
2/4
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 894 times.
✗ Branch 3 not taken.
894 if(!p_getc(&tempMsgString.portrait_y,f))
4066 {
4067 return qe_invalid;
4068 }
4069
4070
2/4
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 894 times.
✗ Branch 3 not taken.
894 if(!p_getc(&tempMsgString.portrait_tw,f))
4071 {
4072 return qe_invalid;
4073 }
4074
4075
2/4
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 894 times.
✗ Branch 3 not taken.
894 if(!p_getc(&tempMsgString.portrait_th,f))
4076 {
4077 return qe_invalid;
4078 }
4079 894 }
4080
4081
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 7038 times.
7932 if(s_version >= 8)
4082 {
4083
2/4
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 894 times.
✗ Branch 3 not taken.
894 if(!p_getc(&tempMsgString.shadow_type,f))
4084 {
4085 return qe_invalid;
4086 }
4087
4088
2/4
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 894 times.
✗ Branch 3 not taken.
894 if(!p_getc(&tempMsgString.shadow_color,f))
4089 {
4090 return qe_invalid;
4091 }
4092 894 }
4093
4094
2/2
✓ Branch 0 taken 777 times.
✓ Branch 1 taken 7155 times.
7932 if(s_version >= 10)
4095 {
4096
2/4
✓ Branch 0 taken 777 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 777 times.
✗ Branch 3 not taken.
777 if(!p_getc(&tempMsgString.drawlayer,f))
4097 {
4098 return qe_invalid;
4099 }
4100 777 }
4101
4102
2/4
✓ Branch 0 taken 7932 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7932 times.
✗ Branch 3 not taken.
7932 if(!p_getc(&tempMsgString.sfx,f))
4103 {
4104 return qe_invalid;
4105 }
4106
4107
1/2
✓ Branch 0 taken 7932 times.
✗ Branch 1 not taken.
7932 if(s_version>3)
4108 {
4109
2/4
✓ Branch 0 taken 7932 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7932 times.
✗ Branch 3 not taken.
7932 if(!p_igetw(&tempMsgString.listpos,f))
4110 {
4111 return qe_invalid;
4112 }
4113 7932 }
4114 }
4115
4116
1/2
✓ Branch 0 taken 27033 times.
✗ Branch 1 not taken.
27033 MsgStrings[i].copyAll(tempMsgString);
4117 27033 }
4118 }
4119
4120 130 msg_count=temp_msg_count;
4121
4122 130 return 0;
4123 130 }
4124
4125 130 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4126 {
4127
2/4
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
130 if((Header->zelda_version < 0x192)||
4128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4129 {
4130 4 return 0;
4131 }
4132
4133 126 word temp_door_combo_set_count=0;
4134 DoorComboSet tempDoorComboSet;
4135 word dummy_word;
4136 int32_t dummy_long;
4137 byte padding;
4138 126 int32_t s_version = 0;
4139
4140
2/2
✓ Branch 0 taken 32256 times.
✓ Branch 1 taken 126 times.
32382 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4141 {
4142 32256 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4143 32256 }
4144
4145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(Header->zelda_version > 0x192)
4146 {
4147 //section version info
4148
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_version,f))
4149 {
4150 return qe_invalid;
4151 }
4152
4153 126 FFCore.quest_format[vDoors] = s_version;
4154
4155 //al_trace("Door combo sets version %d\n", dummy_word);
4156
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&dummy_word,f))
4157 {
4158 return qe_invalid;
4159 }
4160
4161 //section size
4162
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy_long,f))
4163 {
4164 return qe_invalid;
4165 }
4166 126 }
4167
4168 //finally... section data
4169
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&temp_door_combo_set_count,f))
4170 {
4171 return qe_invalid;
4172 }
4173
4174
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 if (!(temp_door_combo_set_count >= 0 && temp_door_combo_set_count <= MAXDOORCOMBOSETS))
4175 {
4176 return qe_invalid;
4177 }
4178
4179
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 126 times.
1134 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4180 {
4181 1008 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4182
4183 //name
4184
1/2
✓ Branch 0 taken 1008 times.
✗ Branch 1 not taken.
1008 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f))
4185 {
4186 return qe_invalid;
4187 }
4188
4189
1/2
✓ Branch 0 taken 1008 times.
✗ Branch 1 not taken.
1008 if(Header->zelda_version < 0x193)
4190 {
4191 if(!p_getc(&padding,f))
4192 {
4193 return qe_invalid;
4194 }
4195 }
4196
4197 //up door
4198
2/2
✓ Branch 0 taken 9072 times.
✓ Branch 1 taken 1008 times.
10080 for(int32_t j=0; j<9; j++)
4199 {
4200
2/2
✓ Branch 0 taken 36288 times.
✓ Branch 1 taken 9072 times.
45360 for(int32_t k=0; k<4; k++)
4201 {
4202
1/2
✓ Branch 0 taken 36288 times.
✗ Branch 1 not taken.
36288 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4203 {
4204 return qe_invalid;
4205 }
4206 36288 }
4207 9072 }
4208
4209
2/2
✓ Branch 0 taken 9072 times.
✓ Branch 1 taken 1008 times.
10080 for(int32_t j=0; j<9; j++)
4210 {
4211
2/2
✓ Branch 0 taken 36288 times.
✓ Branch 1 taken 9072 times.
45360 for(int32_t k=0; k<4; k++)
4212 {
4213
1/2
✓ Branch 0 taken 36288 times.
✗ Branch 1 not taken.
36288 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4214 {
4215 return qe_invalid;
4216 }
4217 36288 }
4218 9072 }
4219
4220 //down door
4221
2/2
✓ Branch 0 taken 9072 times.
✓ Branch 1 taken 1008 times.
10080 for(int32_t j=0; j<9; j++)
4222 {
4223
2/2
✓ Branch 0 taken 36288 times.
✓ Branch 1 taken 9072 times.
45360 for(int32_t k=0; k<4; k++)
4224 {
4225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36288 times.
36288 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4226 {
4227 return qe_invalid;
4228 }
4229 36288 }
4230 9072 }
4231
4232
2/2
✓ Branch 0 taken 9072 times.
✓ Branch 1 taken 1008 times.
10080 for(int32_t j=0; j<9; j++)
4233 {
4234
2/2
✓ Branch 0 taken 36288 times.
✓ Branch 1 taken 9072 times.
45360 for(int32_t k=0; k<4; k++)
4235 {
4236
1/2
✓ Branch 0 taken 36288 times.
✗ Branch 1 not taken.
36288 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4237 {
4238 return qe_invalid;
4239 }
4240 36288 }
4241 9072 }
4242
4243 //left door
4244
2/2
✓ Branch 0 taken 9072 times.
✓ Branch 1 taken 1008 times.
10080 for(int32_t j=0; j<9; j++)
4245 {
4246
2/2
✓ Branch 0 taken 54432 times.
✓ Branch 1 taken 9072 times.
63504 for(int32_t k=0; k<6; k++)
4247 {
4248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54432 times.
54432 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4249 {
4250 return qe_invalid;
4251 }
4252 54432 }
4253 9072 }
4254
4255
2/2
✓ Branch 0 taken 9072 times.
✓ Branch 1 taken 1008 times.
10080 for(int32_t j=0; j<9; j++)
4256 {
4257
2/2
✓ Branch 0 taken 54432 times.
✓ Branch 1 taken 9072 times.
63504 for(int32_t k=0; k<6; k++)
4258 {
4259
1/2
✓ Branch 0 taken 54432 times.
✗ Branch 1 not taken.
54432 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4260 {
4261 return qe_invalid;
4262 }
4263 54432 }
4264 9072 }
4265
4266 //right door
4267
2/2
✓ Branch 0 taken 9072 times.
✓ Branch 1 taken 1008 times.
10080 for(int32_t j=0; j<9; j++)
4268 {
4269
2/2
✓ Branch 0 taken 54432 times.
✓ Branch 1 taken 9072 times.
63504 for(int32_t k=0; k<6; k++)
4270 {
4271
1/2
✓ Branch 0 taken 54432 times.
✗ Branch 1 not taken.
54432 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4272 {
4273 return qe_invalid;
4274 }
4275 54432 }
4276 9072 }
4277
4278
2/2
✓ Branch 0 taken 9072 times.
✓ Branch 1 taken 1008 times.
10080 for(int32_t j=0; j<9; j++)
4279 {
4280
2/2
✓ Branch 0 taken 54432 times.
✓ Branch 1 taken 9072 times.
63504 for(int32_t k=0; k<6; k++)
4281 {
4282
1/2
✓ Branch 0 taken 54432 times.
✗ Branch 1 not taken.
54432 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4283 {
4284 return qe_invalid;
4285 }
4286 54432 }
4287 9072 }
4288
4289 //up bomb rubble
4290
2/2
✓ Branch 0 taken 2016 times.
✓ Branch 1 taken 1008 times.
3024 for(int32_t j=0; j<2; j++)
4291 {
4292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2016 times.
2016 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4293 {
4294 return qe_invalid;
4295 }
4296 2016 }
4297
4298
2/2
✓ Branch 0 taken 2016 times.
✓ Branch 1 taken 1008 times.
3024 for(int32_t j=0; j<2; j++)
4299 {
4300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2016 times.
2016 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4301 {
4302 return qe_invalid;
4303 }
4304 2016 }
4305
4306 //down bomb rubble
4307
2/2
✓ Branch 0 taken 2016 times.
✓ Branch 1 taken 1008 times.
3024 for(int32_t j=0; j<2; j++)
4308 {
4309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2016 times.
2016 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4310 {
4311 return qe_invalid;
4312 }
4313 2016 }
4314
4315
2/2
✓ Branch 0 taken 2016 times.
✓ Branch 1 taken 1008 times.
3024 for(int32_t j=0; j<2; j++)
4316 {
4317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2016 times.
2016 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4318 {
4319 return qe_invalid;
4320 }
4321 2016 }
4322
4323 //left bomb rubble
4324
2/2
✓ Branch 0 taken 3024 times.
✓ Branch 1 taken 1008 times.
4032 for(int32_t j=0; j<3; j++)
4325 {
4326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3024 times.
3024 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4327 {
4328 return qe_invalid;
4329 }
4330 3024 }
4331
4332
2/2
✓ Branch 0 taken 3024 times.
✓ Branch 1 taken 1008 times.
4032 for(int32_t j=0; j<3; j++)
4333 {
4334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3024 times.
3024 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4335 {
4336 return qe_invalid;
4337 }
4338 3024 }
4339
4340
1/2
✓ Branch 0 taken 1008 times.
✗ Branch 1 not taken.
1008 if(Header->zelda_version < 0x193)
4341 {
4342 if(!p_getc(&padding,f))
4343 {
4344 return qe_invalid;
4345 }
4346
4347 }
4348
4349 //right bomb rubble
4350
2/2
✓ Branch 0 taken 3024 times.
✓ Branch 1 taken 1008 times.
4032 for(int32_t j=0; j<3; j++)
4351 {
4352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3024 times.
3024 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4353 {
4354 return qe_invalid;
4355 }
4356 3024 }
4357
4358
2/2
✓ Branch 0 taken 3024 times.
✓ Branch 1 taken 1008 times.
4032 for(int32_t j=0; j<3; j++)
4359 {
4360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3024 times.
3024 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4361 {
4362 return qe_invalid;
4363 }
4364 3024 }
4365
4366
1/2
✓ Branch 0 taken 1008 times.
✗ Branch 1 not taken.
1008 if(Header->zelda_version < 0x193)
4367 {
4368 if(!p_getc(&padding,f))
4369 {
4370 return qe_invalid;
4371 }
4372 }
4373
4374 //walkthrough stuff
4375
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 1008 times.
5040 for(int32_t j=0; j<4; j++)
4376 {
4377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4032 times.
4032 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4378 {
4379 return qe_invalid;
4380 }
4381 4032 }
4382
4383
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 1008 times.
5040 for(int32_t j=0; j<4; j++)
4384 {
4385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4032 times.
4032 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4386 {
4387 return qe_invalid;
4388 }
4389 4032 }
4390
4391 //flags
4392
2/2
✓ Branch 0 taken 2016 times.
✓ Branch 1 taken 1008 times.
3024 for(int32_t j=0; j<2; j++)
4393 {
4394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2016 times.
2016 if(!p_getc(&tempDoorComboSet.flags[j],f))
4395 {
4396 return qe_invalid;
4397 }
4398 2016 }
4399
4400
1/2
✓ Branch 0 taken 1008 times.
✗ Branch 1 not taken.
1008 if(Header->zelda_version < 0x193)
4401 {
4402 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4403 {
4404 return qe_invalid;
4405 }
4406 }
4407
4408 1008 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4409 1008 }
4410
4411 126 door_combo_set_count=temp_door_combo_set_count;
4412
4413 126 return 0;
4414 130 }
4415
4416 int32_t count_dmaps()
4417 {
4418 int32_t i=MAXDMAPS-1;
4419 bool found=false;
4420
4421 while(i>=0 && !found)
4422 {
4423 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4424 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4425 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4426 found=true;
4427
4428 for(int32_t j=0; j<8; j++)
4429 {
4430 if(DMaps[i].grid[j]!=0)
4431
4432 found=true;
4433 }
4434
4435 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4436 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4437 found=true;
4438
4439 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4440 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4441 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4442 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4443 found=true;
4444
4445 if(!found)
4446 {
4447 i--;
4448 }
4449 }
4450
4451 return i+1;
4452 }
4453
4454
4455 int32_t count_shops(miscQdata *Misc)
4456 {
4457 int32_t i=NUM_SHOPS-1,j;
4458 bool found=false;
4459
4460 while(i>=0 && !found)
4461 {
4462 j=2;
4463
4464 while(j>=0 && !found)
4465 {
4466 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4467 {
4468 found=true;
4469 }
4470 else
4471 {
4472 j--;
4473 }
4474 }
4475
4476 if(Misc->shop[i].name[0]!=0)
4477 {
4478 found=true;
4479 }
4480
4481 if(!found)
4482 {
4483 i--;
4484 }
4485 }
4486
4487 return i+1;
4488 }
4489
4490 int32_t count_infos(miscQdata *Misc)
4491 {
4492 int32_t i=255,j;
4493 bool found=false;
4494
4495 while(i>=0 && !found)
4496 {
4497 j=2;
4498
4499 while(j>=0 && !found)
4500 {
4501 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4502 {
4503 found=true;
4504 }
4505 else
4506 {
4507 j--;
4508 }
4509 }
4510
4511 if(Misc->info[i].name[0]!=0)
4512 {
4513 found=true;
4514 }
4515
4516 if(!found)
4517 {
4518 i--;
4519 }
4520 }
4521
4522 return i+1;
4523 }
4524
4525 int32_t count_warprings(miscQdata *Misc)
4526 {
4527 int32_t i=15,j;
4528 bool found=false;
4529
4530 while(i>=0 && !found)
4531 {
4532 j=7;
4533
4534 while(j>=0 && !found)
4535 {
4536 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4537 {
4538 found=true;
4539 }
4540 else
4541 {
4542 j--;
4543 }
4544 }
4545
4546 if(!found)
4547 {
4548 i--;
4549 }
4550 }
4551
4552 return i+1;
4553 }
4554
4555 int32_t count_palcycles(miscQdata *Misc)
4556 {
4557 int32_t i=255,j;
4558 bool found=false;
4559
4560 while(i>=0 && !found)
4561 {
4562 j=2;
4563
4564 while(j>=0 && !found)
4565 {
4566 if(Misc->cycles[i][j].count!=0)
4567 {
4568 found=true;
4569 }
4570 else
4571 {
4572 j--;
4573 }
4574 }
4575
4576 if(!found)
4577 {
4578 i--;
4579 }
4580 }
4581
4582 return i+1;
4583 }
4584
4585 264986 void clear_screen(mapscr *temp_scr)
4586 {
4587 264986 temp_scr->zero_memory();
4588 264986 }
4589
4590 130 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4591 {
4592 130 word dmapstoread=0;
4593 dmap tempDMap;
4594
4595 int32_t dummy;
4596 130 word s_version=0, s_cversion=0;
4597 byte padding;
4598
4599
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 130 times.
66690 for(int32_t i=0; i<max_dmaps; i++)
4600 {
4601 66560 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4602 66560 sprintf(DMaps[start_dmap+i].title," ");
4603 66560 sprintf(DMaps[start_dmap+i].intro," ");
4604 66560 DMaps[start_dmap+i].type |= dmCAVE;
4605 66560 }
4606
4607
3/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 4 times.
130 if(!Header || Header->zelda_version > 0x192)
4608 {
4609 //section version info
4610
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_version,f))
4611 {
4612 return qe_invalid;
4613 }
4614
4615 126 FFCore.quest_format[vDMaps] = s_version;
4616
4617 //al_trace("DMaps version %d\n", s_version);
4618
4619
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_cversion,f))
4620 {
4621 return qe_invalid;
4622 }
4623
4624 //section size
4625
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy,f))
4626 {
4627 return qe_invalid;
4628 }
4629
4630 //finally... section data
4631
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&dmapstoread,f))
4632 {
4633 return qe_invalid;
4634 }
4635 126 }
4636 else
4637 {
4638
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
4639 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4640 {
4641 4 dmapstoread=32;
4642 4 }
4643 else if(s_version <= 4)
4644 {
4645 dmapstoread=OLDMAXDMAPS;
4646 }
4647 else
4648 {
4649 dmapstoread=MAXDMAPS;
4650 }
4651 }
4652
4653
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 114 times.
130 dmapstoread=zc_min(dmapstoread, max_dmaps);
4654
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 114 times.
130 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4655
4656
2/2
✓ Branch 0 taken 61568 times.
✓ Branch 1 taken 130 times.
61698 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4657 {
4658 61568 memset(&tempDMap,0,sizeof(dmap));
4659 61568 sprintf(tempDMap.title," ");
4660 61568 sprintf(tempDMap.intro," ");
4661
4662
1/2
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
61568 if(!p_getc(&tempDMap.map,f))
4663 {
4664 return qe_invalid;
4665 }
4666
4667
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 58368 times.
61568 if(s_version <= 4)
4668 {
4669 byte tempbyte;
4670
4671
1/2
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
3200 if(!p_getc(&tempbyte,f))
4672 {
4673 return qe_invalid;
4674 }
4675
4676 3200 tempDMap.level=(word)tempbyte;
4677 3200 }
4678 else
4679 {
4680
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&tempDMap.level,f))
4681 {
4682 return qe_invalid;
4683 }
4684 }
4685
4686
1/2
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
61568 if(!p_getc(&tempDMap.xoff,f))
4687 {
4688 return qe_invalid;
4689 }
4690
4691
1/2
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
61568 if(!p_getc(&tempDMap.compass,f))
4692 {
4693 return qe_invalid;
4694 }
4695
4696
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 3200 times.
61568 if(s_version > 8) // February 2009
4697 {
4698
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&tempDMap.color,f))
4699 {
4700 return qe_invalid;
4701 }
4702 58368 }
4703 else
4704 {
4705 byte tempbyte;
4706
4707
1/2
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
3200 if(!p_getc(&tempbyte,f))
4708 {
4709 return qe_invalid;
4710 }
4711
4712 3200 tempDMap.color = (word)tempbyte;
4713 }
4714
4715
1/2
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
61568 if(!p_getc(&tempDMap.midi,f))
4716 {
4717 return qe_invalid;
4718 }
4719
4720
1/2
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
61568 if(!p_getc(&tempDMap.cont,f))
4721 {
4722 return qe_invalid;
4723 }
4724
4725
1/2
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
61568 if(!p_getc(&tempDMap.type,f))
4726 {
4727 return qe_invalid;
4728 }
4729
4730
4/4
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 60736 times.
✓ Branch 2 taken 820 times.
✓ Branch 3 taken 12 times.
62400 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4731
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4732 820 tempDMap.xoff = 0;
4733
4734
2/2
✓ Branch 0 taken 492544 times.
✓ Branch 1 taken 61568 times.
554112 for(int32_t j=0; j<8; j++)
4735 {
4736
1/2
✓ Branch 0 taken 492544 times.
✗ Branch 1 not taken.
492544 if(!p_getc(&tempDMap.grid[j],f))
4737 {
4738 return qe_invalid;
4739 }
4740 492544 }
4741
4742
4/8
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61440 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 61440 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
61568 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4743 {
4744
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
128 if(tempDMap.level>0&&tempDMap.level<10)
4745 {
4746 38 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4747 38 }
4748
4749
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
128 if(i==0 && Header->zelda_version <= 0x190)
4750 {
4751 4 tempDMap.cont-=tempDMap.xoff;
4752 4 tempDMap.compass-=tempDMap.xoff;
4753 4 }
4754
4755 //forgotten -DD
4756
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
128 if(tempDMap.level==0)
4757 {
4758 90 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4759 90 }
4760 128 }
4761 else
4762 {
4763
1/2
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
61440 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f))
4764 {
4765 return qe_invalid;
4766 }
4767
4768
1/2
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
61440 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f))
4769 {
4770 return qe_invalid;
4771 }
4772
4773
1/2
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
61440 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f))
4774 {
4775 return qe_invalid;
4776 }
4777
4778
3/8
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61440 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 61440 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
61440 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4779 {
4780 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4781 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4782
4783 continue;
4784 }
4785
4786
2/4
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61440 times.
✗ Branch 3 not taken.
61440 if(Header && (Header->zelda_version < 0x193))
4787 {
4788 if(!p_getc(&padding,f))
4789 {
4790 return qe_invalid;
4791 }
4792 }
4793
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42496 times.
61440 if ( s_version >= 11 )
4794 {
4795
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&tempDMap.minimap_1_tile,f))
4796 {
4797 return qe_invalid;
4798 }
4799 18944 }
4800 else
4801 {
4802
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.minimap_1_tile,f))
4803 {
4804 return qe_invalid;
4805 }
4806 }
4807
4808
1/2
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
61440 if(!p_getc(&tempDMap.minimap_1_cset,f))
4809 {
4810 return qe_invalid;
4811 }
4812
4813
2/4
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61440 times.
✗ Branch 3 not taken.
61440 if(Header && (Header->zelda_version < 0x193))
4814 {
4815 if(!p_getc(&padding,f))
4816 {
4817 return qe_invalid;
4818 }
4819 }
4820
4821
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42496 times.
61440 if ( s_version >= 11 )
4822 {
4823
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&tempDMap.minimap_2_tile,f))
4824 {
4825 return qe_invalid;
4826 }
4827 18944 }
4828 else
4829 {
4830
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.minimap_2_tile,f))
4831 {
4832 return qe_invalid;
4833 }
4834 }
4835
1/2
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
61440 if(!p_getc(&tempDMap.minimap_2_cset,f))
4836 {
4837 return qe_invalid;
4838 }
4839
4840
2/4
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61440 times.
✗ Branch 3 not taken.
61440 if(Header && (Header->zelda_version < 0x193))
4841 {
4842 if(!p_getc(&padding,f))
4843 {
4844 return qe_invalid;
4845 }
4846 }
4847
4848
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42496 times.
61440 if ( s_version >= 11 )
4849 {
4850
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&tempDMap.largemap_1_tile,f))
4851 {
4852 return qe_invalid;
4853 }
4854 18944 }
4855 else
4856 {
4857
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.largemap_1_tile,f))
4858 {
4859 return qe_invalid;
4860 }
4861 }
4862
4863
1/2
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
61440 if(!p_getc(&tempDMap.largemap_1_cset,f))
4864 {
4865 return qe_invalid;
4866 }
4867
4868
2/4
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61440 times.
✗ Branch 3 not taken.
61440 if(Header && (Header->zelda_version < 0x193))
4869 {
4870
4871 if(!p_getc(&padding,f))
4872 {
4873 return qe_invalid;
4874 }
4875 }
4876
4877
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42496 times.
61440 if ( s_version >= 11 )
4878 {
4879
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&tempDMap.largemap_2_tile,f))
4880 {
4881 return qe_invalid;
4882 }
4883 18944 }
4884 else
4885 {
4886
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.largemap_2_tile,f))
4887 {
4888 return qe_invalid;
4889 }
4890 }
4891
1/2
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
61440 if(!p_getc(&tempDMap.largemap_2_cset,f))
4892 {
4893 return qe_invalid;
4894 }
4895
4896
1/2
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
61440 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f))
4897 {
4898 return qe_invalid;
4899 }
4900 }
4901
4902
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 58368 times.
61568 if(s_version>1)
4903 {
4904
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&tempDMap.tmusictrack,f))
4905 {
4906 return qe_invalid;
4907 }
4908
4909
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&tempDMap.active_subscreen,f))
4910 {
4911 return qe_invalid;
4912 }
4913
4914
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&tempDMap.passive_subscreen,f))
4915 {
4916 return qe_invalid;
4917 }
4918 58368 }
4919
4920
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 58368 times.
61568 if(s_version>2)
4921 {
4922 byte di[32];
4923
4924
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!pfread(&di, 32, f)) return qe_invalid;
4925
4926
2/2
✓ Branch 0 taken 14942208 times.
✓ Branch 1 taken 58368 times.
15000576 for(int32_t j=0; j<MAXITEMS; j++)
4927 {
4928
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 14942201 times.
14942208 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4929 14942201 else tempDMap.disableditems[j]=0;
4930 14942208 }
4931 58368 }
4932
4933
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 3200 times.
61568 if(s_version >= 6)
4934 {
4935
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&tempDMap.flags,f))
4936 {
4937 return qe_invalid;
4938 }
4939 58368 }
4940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3200 times.
3200 else if(s_version>3)
4941 {
4942 char temp;
4943
4944 if(!p_getc(&temp,f))
4945 {
4946 return qe_invalid;
4947 }
4948
4949 tempDMap.flags = temp;
4950 }
4951
3/8
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 816 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3200 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4952 {
4953 816 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4954 816 }
4955 else
4956 2384 tempDMap.flags=0;
4957
4958
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 3200 times.
61568 if(s_version<7)
4959 {
4960
3/4
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 816 times.
3200 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4961 816 tempDMap.flags|= dmfVIEWMAP;
4962 3200 }
4963
4964
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 3200 times.
61568 if(s_version<8)
4965 {
4966
4/4
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✓ Branch 2 taken 207 times.
✓ Branch 3 taken 609 times.
3200 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4967 {
4968 609 tempDMap.type &= ~dmDNGN;
4969 609 tempDMap.type |= dmCAVE;
4970 609 }
4971
2/2
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1736 times.
2591 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4972 {
4973 1736 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4974 1736 }
4975 3200 }
4976
4977
5/8
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 61440 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128 times.
✓ Branch 6 taken 61440 times.
✗ Branch 7 not taken.
61568 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4978 61440 && (Header->zelda_version < 0x193))
4979 {
4980 if(!p_getc(&padding,f))
4981 {
4982 return qe_invalid;
4983 }
4984 }
4985
4986
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 18944 times.
61568 if(s_version >= 10)
4987 {
4988
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&tempDMap.sideview,f))
4989 {
4990 return qe_invalid;
4991 }
4992 18944 }
4993
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42624 times.
61568 if(s_version < 10) tempDMap.sideview = 0;
4994
4995 //Dmap Scripts
4996
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 18944 times.
61568 if(s_version >= 12)
4997 {
4998
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetw(&tempDMap.script,f))
4999 {
5000 return qe_invalid;
5001 }
5002
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for ( int32_t q = 0; q < 8; q++ )
5003 {
5004
1/2
✓ Branch 0 taken 151552 times.
✗ Branch 1 not taken.
151552 if(!p_igetl(&tempDMap.initD[q],f))
5005 {
5006 return qe_invalid;
5007 }
5008 151552 }
5009 18944 }
5010
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42624 times.
61568 if ( s_version < 12 )
5011 {
5012 42624 tempDMap.script = 0;
5013
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5014 {
5015 340992 tempDMap.initD[q] = 0;
5016 340992 }
5017 42624 }
5018
5019
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 18944 times.
61568 if(s_version >= 13)
5020 {
5021
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for ( int32_t q = 0; q < 8; q++ )
5022 {
5023
2/2
✓ Branch 0 taken 9850880 times.
✓ Branch 1 taken 151552 times.
10002432 for ( int32_t w = 0; w < 65; w++ )
5024 {
5025
1/2
✓ Branch 0 taken 9850880 times.
✗ Branch 1 not taken.
9850880 if(!p_getc(&tempDMap.initD_label[q][w],f))
5026 {
5027 return qe_invalid;
5028 }
5029 9850880 }
5030 151552 }
5031 18944 }
5032
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42624 times.
61568 if ( s_version < 13 )
5033 {
5034 42624 tempDMap.script = 0;
5035
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5036 {
5037
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for ( int32_t w = 0; w < 65; w++ )
5038 22164480 tempDMap.initD_label[q][w] = 0;
5039 340992 }
5040 42624 }
5041
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42624 times.
61568 if(s_version >= 14)
5042 {
5043
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetw(&tempDMap.active_sub_script,f))
5044 {
5045 return qe_invalid;
5046 }
5047
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetw(&tempDMap.passive_sub_script,f))
5048 {
5049 return qe_invalid;
5050 }
5051
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for ( int32_t q = 0; q < 8; ++q )
5052 {
5053
1/2
✓ Branch 0 taken 151552 times.
✗ Branch 1 not taken.
151552 if(!p_igetl(&tempDMap.sub_initD[q],f))
5054 {
5055 return qe_invalid;
5056 }
5057 151552 }
5058
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for(int32_t q = 0; q < 8; ++q)
5059 {
5060
2/2
✓ Branch 0 taken 9850880 times.
✓ Branch 1 taken 151552 times.
10002432 for ( int32_t w = 0; w < 65; ++w )
5061 {
5062
1/2
✓ Branch 0 taken 9850880 times.
✗ Branch 1 not taken.
9850880 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
5063 {
5064 return qe_invalid;
5065 }
5066 9850880 }
5067 151552 }
5068 18944 }
5069 else
5070 {
5071 42624 tempDMap.active_sub_script = 0;
5072 42624 tempDMap.passive_sub_script = 0;
5073
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5074 {
5075 340992 tempDMap.sub_initD[q] = 0;
5076
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5077 22164480 tempDMap.sub_initD_label[q][w] = 0;
5078 340992 }
5079 }
5080
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42624 times.
61568 if(s_version >= 15)
5081 {
5082
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetw(&tempDMap.onmap_script,f))
5083 {
5084 return qe_invalid;
5085 }
5086
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for ( int32_t q = 0; q < 8; ++q )
5087 {
5088
1/2
✓ Branch 0 taken 151552 times.
✗ Branch 1 not taken.
151552 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5089 {
5090 return qe_invalid;
5091 }
5092 151552 }
5093
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for(int32_t q = 0; q < 8; ++q)
5094 {
5095
2/2
✓ Branch 0 taken 9850880 times.
✓ Branch 1 taken 151552 times.
10002432 for ( int32_t w = 0; w < 65; ++w )
5096 {
5097
1/2
✓ Branch 0 taken 9850880 times.
✗ Branch 1 not taken.
9850880 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5098 {
5099 return qe_invalid;
5100 }
5101 9850880 }
5102 151552 }
5103 18944 }
5104 else
5105 {
5106 42624 tempDMap.onmap_script = 0;
5107
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5108 {
5109 340992 tempDMap.onmap_initD[q] = 0;
5110
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5111 {
5112 22164480 tempDMap.onmap_initD_label[q][w] = 0;
5113 22164480 }
5114 340992 }
5115 }
5116
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42624 times.
61568 if(s_version >= 16)
5117 {
5118
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetw(&tempDMap.mirrorDMap,f))
5119 {
5120 return qe_invalid;
5121 }
5122 18944 }
5123 else
5124 {
5125 42624 tempDMap.mirrorDMap = -1;
5126 }
5127
5128
2/2
✓ Branch 0 taken 47232 times.
✓ Branch 1 taken 14336 times.
61568 if (s_version >= 17)
5129 {
5130 // Reserved for z3.
5131 14336 }
5132
5133 // Enhanced music loop points
5134
2/2
✓ Branch 0 taken 14336 times.
✓ Branch 1 taken 47232 times.
61568 if (s_version >= 18)
5135 {
5136
1/2
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
14336 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
5137 {
5138 return qe_invalid;
5139 }
5140
1/2
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
14336 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
5141 {
5142 return qe_invalid;
5143 }
5144
1/2
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
14336 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5145 {
5146 return qe_invalid;
5147 }
5148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14336 times.
14336 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5149 {
5150 return qe_invalid;
5151 }
5152 14336 }
5153 else
5154 {
5155 47232 tempDMap.tmusic_loop_start = 0;
5156 47232 tempDMap.tmusic_loop_end = 0;
5157 47232 tempDMap.tmusic_xfade_in = 0;
5158 47232 tempDMap.tmusic_xfade_out = 0;
5159 }
5160
5161
2/2
✓ Branch 0 taken 47232 times.
✓ Branch 1 taken 14336 times.
61568 if(s_version >= 19)
5162
1/2
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
14336 if(!p_getc(&tempDMap.overlay_subscreen, f))
5163 return qe_invalid;
5164
5165 61568 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5166 61568 }
5167
5168 130 return 0;
5169 130 }
5170
5171 114 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5172 {
5173 //these are here to bypass compiler warnings about unused arguments
5174 114 Header=Header;
5175
5176 miscQdata temp_misc;
5177 114 word s_version=0, s_cversion=0;
5178 114 int32_t tempsize=0;
5179 word dummyw;
5180
5181 114 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5182
5183 //section version info
5184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_igetw(&s_version,f))
5185 {
5186 return qe_invalid;
5187 }
5188
5189 114 FFCore.quest_format[vColours] = s_version;
5190
5191 114 al_trace("Misc Colours section version: %d\n", s_version);
5192
5193 //al_trace("Misc. colors version %d\n", s_version);
5194
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&s_cversion,f))
5195 {
5196 return qe_invalid;
5197 }
5198
5199
5200 //section size
5201
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&tempsize,f))
5202 {
5203 return qe_invalid;
5204 }
5205
5206 //finally... section data
5207 114 readsize=0;
5208
5209
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.text,f))
5210 {
5211 return qe_invalid;
5212 }
5213
5214
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.caption,f))
5215 {
5216 return qe_invalid;
5217 }
5218
5219
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.overw_bg,f))
5220 {
5221 return qe_invalid;
5222 }
5223
5224
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5225 {
5226 return qe_invalid;
5227 }
5228
5229
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5230 {
5231 return qe_invalid;
5232 }
5233
5234
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.cave_fg,f))
5235 {
5236 return qe_invalid;
5237 }
5238
5239
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.bs_dk,f))
5240 {
5241 return qe_invalid;
5242 }
5243
5244
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.bs_goal,f))
5245 {
5246 return qe_invalid;
5247 }
5248
5249
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.compass_lt,f))
5250 {
5251 return qe_invalid;
5252 }
5253
5254
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.compass_dk,f))
5255 {
5256 return qe_invalid;
5257 }
5258
5259
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5260 {
5261 return qe_invalid;
5262 }
5263
5264
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.triframe_color,f))
5265 {
5266 return qe_invalid;
5267 }
5268
5269
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.hero_dot,f))
5270 {
5271 return qe_invalid;
5272 }
5273
5274
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5275 {
5276 return qe_invalid;
5277 }
5278
5279
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5280 {
5281 return qe_invalid;
5282 }
5283
5284
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5285 {
5286 return qe_invalid;
5287 }
5288
5289
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5290 {
5291 return qe_invalid;
5292 }
5293
5294
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5295 {
5296 return qe_invalid;
5297 }
5298
5299
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5300 {
5301 return qe_invalid;
5302 }
5303
5304
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5305 {
5306 return qe_invalid;
5307 }
5308
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 77 times.
114 if(s_version < 4)
5309 {
5310
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5311 return qe_invalid;
5312 77 temp_misc.colors.triforce_tile = dummyw;
5313
5314
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5315 return qe_invalid;
5316 77 temp_misc.colors.triframe_tile = dummyw;
5317
5318
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5319 return qe_invalid;
5320 77 temp_misc.colors.overworld_map_tile = dummyw;
5321
5322
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5323 return qe_invalid;
5324 77 temp_misc.colors.dungeon_map_tile = dummyw;
5325
5326
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5327 return qe_invalid;
5328 77 temp_misc.colors.blueframe_tile = dummyw;
5329
5330
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5331 return qe_invalid;
5332 77 temp_misc.colors.HCpieces_tile = dummyw;
5333 77 }
5334
5335
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5336 {
5337 return qe_invalid;
5338 }
5339
5340
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5341 {
5342 return qe_invalid;
5343 }
5344
5345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(s_version < 2)
5346 {
5347 temp_misc.colors.msgtext = 0x01;
5348 }
5349 else
5350 {
5351
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.msgtext, f))
5352 {
5353 return qe_invalid;
5354 }
5355 }
5356
5357
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if ( s_version >= 3 ) //expanded tile pages to 825
5358 {
5359
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5360 {
5361 return qe_invalid;
5362 }
5363
5364
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5365 {
5366 return qe_invalid;
5367 }
5368
5369
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5370 {
5371 return qe_invalid;
5372 }
5373
5374
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5375 {
5376 return qe_invalid;
5377 }
5378
5379
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5380 {
5381 return qe_invalid;
5382 }
5383
5384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5385 {
5386 return qe_invalid;
5387 }
5388 37 }
5389
5390 114 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5391
5392 114 return 0;
5393 114 }
5394
5395 114 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5396 {
5397 miscQdata temp_misc;
5398 114 word s_version=0, s_cversion=0;
5399 byte icons;
5400 114 int32_t tempsize=0;
5401
5402 114 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5403
5404 //section version info
5405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_igetw(&s_version,f))
5406 {
5407 return qe_invalid;
5408 }
5409
5410 114 FFCore.quest_format[vIcons] = s_version;
5411
5412 //al_trace("Game icons version %d\n", s_version);
5413
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&s_cversion,f))
5414 {
5415 return qe_invalid;
5416 }
5417
5418
5419 //section size
5420
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&tempsize,f))
5421 {
5422 return qe_invalid;
5423 }
5424
5425 //finally... section data
5426 114 readsize=0;
5427
5428 114 icons=4;
5429
5430
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 77 times.
114 if ( s_version >= 10 )
5431 {
5432
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<icons; i++)
5433 {
5434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_igetl(&temp_misc.icons[i],f))
5435 {
5436 return qe_invalid;
5437 }
5438 148 }
5439 37 }
5440 else
5441 {
5442
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<icons; i++)
5443 {
5444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if(!p_igetw(&temp_misc.icons[i],f))
5445 {
5446 return qe_invalid;
5447 }
5448 308 }
5449 }
5450
5451 114 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5452
5453 114 return 0;
5454 114 }
5455
5456 130 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5457 {
5458 130 word maxinfos=256;
5459 130 word maxshops=256;
5460 130 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5461 130 word ponds=16, pondsize=72, expansionsize=98*2;
5462 byte tempbyte, padding;
5463 miscQdata temp_misc;
5464 130 word s_version=0, s_cversion=0;
5465 word swaptmp;
5466 130 int32_t tempsize=0;
5467
5468 130 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5469
5470
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<maxshops; ++i)
5471 {
5472 33280 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5473 33280 }
5474
5475
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<maxinfos; ++i)
5476 {
5477 33280 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5478 33280 }
5479
5480
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version > 0x192)
5481 {
5482 //section version info
5483
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_version,f))
5484 {
5485 return qe_invalid;
5486 }
5487
5488 126 FFCore.quest_format[vMisc] = s_version;
5489
5490 //al_trace("Misc. data version %d\n", s_version);
5491
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_cversion,f))
5492 {
5493 return qe_invalid;
5494 }
5495
5496
5497 //section size
5498
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&tempsize,f))
5499 {
5500 return qe_invalid;
5501 }
5502 126 }
5503
5504 //finally... section data
5505 130 readsize=0;
5506
5507 //shops
5508
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version > 0x192)
5509 {
5510
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&shops,f))
5511 {
5512 return qe_invalid;
5513 }
5514 126 }
5515
5516
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 130 times.
130 if (!(shops >= 0 && shops <= NUM_SHOPS))
5517 {
5518 return qe_invalid;
5519 }
5520
5521
2/2
✓ Branch 0 taken 1472 times.
✓ Branch 1 taken 130 times.
1602 for(int32_t i=0; i<shops; i++)
5522 {
5523
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1249 times.
1472 if(s_version > 6)
5524 {
5525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1249 times.
1249 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f))
5526 {
5527 return qe_invalid;
5528 }
5529 1249 }
5530
5531
2/2
✓ Branch 0 taken 4416 times.
✓ Branch 1 taken 1472 times.
5888 for(int32_t j=0; j<3; j++)
5532 {
5533
1/2
✓ Branch 0 taken 4416 times.
✗ Branch 1 not taken.
4416 if(!p_getc(&temp_misc.shop[i].item[j],f))
5534 {
5535 return qe_invalid;
5536 }
5537
5538
2/2
✓ Branch 0 taken 3747 times.
✓ Branch 1 taken 669 times.
4416 if(s_version < 4)
5539 {
5540 669 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5541 669 }
5542 4416 }
5543
5544
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 64 times.
1472 if(Header->zelda_version < 0x193)
5545 {
5546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(!p_getc(&tempbyte,f))
5547 {
5548 return qe_invalid;
5549 }
5550 64 }
5551
5552
2/2
✓ Branch 0 taken 4416 times.
✓ Branch 1 taken 1472 times.
5888 for(int32_t j=0; j<3; j++)
5553 {
5554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4416 times.
4416 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5555 {
5556 return qe_invalid;
5557 }
5558 4416 }
5559
5560
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1249 times.
1472 if(s_version > 3)
5561 {
5562
2/2
✓ Branch 0 taken 3747 times.
✓ Branch 1 taken 1249 times.
4996 for(int32_t j=0; j<3; j++)
5563 {
5564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3747 times.
3747 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5565 return qe_invalid;
5566 3747 }
5567 1249 }
5568
5569 /*
5570 if(s_version < 8)
5571 {
5572 for(int32_t j=0; j<3; j++)
5573 {
5574 (&temp_misc.shop[i].str[j])=0; //initialise.
5575 }
5576 }
5577 */
5578 1472 }
5579
5580 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5581
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<maxshops; ++i)
5582 {
5583
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 33280 times.
99840 for(int32_t j=0; j<3-1; j++)
5584 {
5585
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 96831 times.
163391 for(int32_t k=0; k<2-j; k++)
5586 {
5587 96831 if(temp_misc.shop[i].hasitem[k]==0)
5588 {
5589 96831 swaptmp = temp_misc.shop[i].item[k];
5590 96831 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5591 96831 temp_misc.shop[i].item[k+1] = swaptmp;
5592 96831 swaptmp = temp_misc.shop[i].price[k];
5593 96831 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5594 96831 temp_misc.shop[i].price[k+1] = swaptmp;
5595 96831 swaptmp = temp_misc.shop[i].hasitem[k];
5596 96831 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5597 96831 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5598 96831 }
5599 96831 }
5600 66560 }
5601 33280 }
5602
5603 //infos
5604
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version > 0x192)
5605 {
5606
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&infos,f))
5607 {
5608 return qe_invalid;
5609 }
5610 126 }
5611
5612
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 130 times.
130 if (!(infos >= 0 && infos <= NUM_INFOS))
5613 {
5614 return qe_invalid;
5615 }
5616
5617
5618
2/2
✓ Branch 0 taken 1783 times.
✓ Branch 1 taken 130 times.
1913 for(int32_t i=0; i<infos; i++)
5619 {
5620
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 1683 times.
1783 if(s_version > 6)
5621 {
5622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1683 times.
1683 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f))
5623 {
5624 return qe_invalid;
5625 }
5626 1683 }
5627
5628
2/2
✓ Branch 0 taken 5349 times.
✓ Branch 1 taken 1783 times.
7132 for(int32_t j=0; j<3; j++)
5629 {
5630
2/4
✓ Branch 0 taken 5157 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5349 if((Header->zelda_version < 0x192)||
5631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5157 times.
5157 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5632 {
5633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5634 {
5635 return qe_invalid;
5636 }
5637
5638 192 temp_misc.info[i].str[j]=tempbyte;
5639 192 }
5640 else
5641 {
5642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5157 times.
5157 if(!p_igetw(&temp_misc.info[i].str[j],f))
5643 {
5644 return qe_invalid;
5645 }
5646 }
5647 5349 }
5648
5649
2/2
✓ Branch 0 taken 1719 times.
✓ Branch 1 taken 64 times.
1783 if(Header->zelda_version < 0x193)
5650 {
5651
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbyte,f))
5652 {
5653 return qe_invalid;
5654 }
5655 64 }
5656
5657
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1783 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1783 if((Header->zelda_version == 0x192)&&(Header->build>145))
5658 {
5659 if(!p_getc(&padding,f))
5660 {
5661 return qe_invalid;
5662 }
5663 }
5664
5665
2/2
✓ Branch 0 taken 5349 times.
✓ Branch 1 taken 1783 times.
7132 for(int32_t j=0; j<3; j++)
5666 {
5667
1/2
✓ Branch 0 taken 5349 times.
✗ Branch 1 not taken.
5349 if(!p_igetw(&temp_misc.info[i].price[j],f))
5668 {
5669 return qe_invalid;
5670 }
5671 5349 }
5672 1783 }
5673
5674 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5675
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<maxinfos; ++i)
5676 {
5677
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 33280 times.
99840 for(int32_t j=0; j<3-1; j++)
5678 {
5679
2/2
✓ Branch 0 taken 99840 times.
✓ Branch 1 taken 66560 times.
166400 for(int32_t k=0; k<2-j; k++)
5680 {
5681
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 97728 times.
99840 if(temp_misc.info[i].str[k]==0)
5682 {
5683 97728 swaptmp = temp_misc.info[i].str[k];
5684 97728 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5685 97728 temp_misc.info[i].str[k+1] = swaptmp;
5686 97728 swaptmp = temp_misc.info[i].price[k];
5687 97728 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5688 97728 temp_misc.info[i].price[k+1] = swaptmp;
5689 97728 }
5690 99840 }
5691 66560 }
5692 33280 }
5693
5694
5695 //warp rings
5696
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 114 times.
130 if(s_version > 5)
5697 114 warprings++;
5698
5699
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version > 0x192)
5700 {
5701
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&warprings,f))
5702 {
5703 return qe_invalid;
5704 }
5705
5706
3/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 38 times.
126 if (!(warprings >= 0 && warprings <= NUM_WARP_RINGS))
5707 {
5708 // return qe_invalid;
5709 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5710 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5711 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5712 38 }
5713 126 }
5714
5715
2/2
✓ Branch 0 taken 1307 times.
✓ Branch 1 taken 130 times.
1437 for(int32_t i=0; i<warprings; i++)
5716 {
5717 // See above comment on the `warprings` range check.
5718 1307 bool keepdata = i < NUM_WARP_RINGS;
5719
5720
2/2
✓ Branch 0 taken 11539 times.
✓ Branch 1 taken 1307 times.
12846 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5721 {
5722
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 9747 times.
11539 if(s_version <= 3)
5723 {
5724
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(!p_getc(&tempbyte,f))
5725 {
5726 return qe_invalid;
5727 }
5728
5729
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 1120 times.
1792 if (keepdata)
5730 1120 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5731 1792 }
5732 else
5733 {
5734 word tempword;
5735
1/2
✓ Branch 0 taken 9747 times.
✗ Branch 1 not taken.
9747 if(!p_igetw(&tempword,f))
5736 {
5737 return qe_invalid;
5738 }
5739
5740
2/2
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 9234 times.
9747 if (keepdata)
5741 9234 temp_misc.warp[i].dmap[j] = tempword;
5742 }
5743 11539 }
5744
5745
2/2
✓ Branch 0 taken 11539 times.
✓ Branch 1 taken 1307 times.
12846 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5746 {
5747
1/2
✓ Branch 0 taken 11539 times.
✗ Branch 1 not taken.
11539 if(!p_getc(&tempbyte,f))
5748 {
5749 return qe_invalid;
5750 }
5751
2/2
✓ Branch 0 taken 1185 times.
✓ Branch 1 taken 10354 times.
11539 if (keepdata)
5752 10354 temp_misc.warp[i].scr[j] = tempbyte;
5753 11539 }
5754
5755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1307 times.
1307 if(!p_getc(&tempbyte,f))
5756 {
5757 return qe_invalid;
5758 }
5759
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1166 times.
1307 if (keepdata)
5760 1166 temp_misc.warp[i].size = tempbyte;
5761
5762
2/2
✓ Branch 0 taken 1275 times.
✓ Branch 1 taken 32 times.
1307 if(Header->zelda_version < 0x193)
5763 {
5764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&tempbyte,f))
5765 {
5766 return qe_invalid;
5767 }
5768 32 }
5769 1307 }
5770
5771 //palette cycles
5772
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5773 {
5774
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<256; i++)
5775 {
5776
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1024 times.
4096 for(int32_t j=0; j<3; j++)
5777 {
5778 3072 temp_misc.cycles[i][j].first=0;
5779 3072 temp_misc.cycles[i][j].count=0;
5780 3072 temp_misc.cycles[i][j].speed=0;
5781 3072 }
5782 1024 }
5783
5784
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
5785 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5786 {
5787 4 palcycles=16;
5788 4 }
5789
5790
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4 times.
68 for(int32_t i=0; i<palcycles; i++)
5791 {
5792
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 64 times.
256 for(int32_t j=0; j<3; j++)
5793 {
5794
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5795 {
5796 return qe_invalid;
5797 }
5798
5799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5800 {
5801 return qe_invalid;
5802 }
5803
5804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5805 {
5806 return qe_invalid;
5807 }
5808 192 }
5809 64 }
5810 4 }
5811
5812 //Wind warps are now just another warp ring.
5813
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version <= 5)
5814 {
5815
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(Header->zelda_version > 0x192)
5816 {
5817
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&windwarps,f))
5818 {
5819 return qe_invalid;
5820 }
5821 12 }
5822
5823
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
16 if (!(windwarps >= 0 && windwarps <= NUM_WARP_RINGS))
5824 {
5825 return qe_invalid;
5826 }
5827
5828
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 16 times.
151 for(int32_t i=0; i<windwarps; i++)
5829 {
5830
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version <= 3)
5831 {
5832
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&tempbyte,f))
5833 {
5834 return qe_invalid;
5835 }
5836
5837 135 temp_misc.warp[8].dmap[i]=tempbyte;
5838 135 }
5839 else
5840 {
5841 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5842 {
5843 return qe_invalid;
5844 }
5845 }
5846
5847
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5848 {
5849 return qe_invalid;
5850 }
5851
5852 135 temp_misc.warp[8].size = 9;
5853
5854
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version == 5)
5855 {
5856 if(!p_getc(&tempbyte,f))
5857 {
5858 return qe_invalid;
5859 }
5860 }
5861 135 }
5862 16 }
5863
5864
5865 //triforce pieces
5866
2/2
✓ Branch 0 taken 1040 times.
✓ Branch 1 taken 130 times.
1170 for(int32_t i=0; i<triforces; i++)
5867 {
5868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1040 times.
1040 if(!p_getc(&temp_misc.triforce[i],f))
5869 {
5870 return qe_invalid;
5871 }
5872 1040 }
5873
5874 //misc color data
5875
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<3)
5876 {
5877
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.text,f))
5878 {
5879 return qe_invalid;
5880 }
5881
5882
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.caption,f))
5883 {
5884 return qe_invalid;
5885 }
5886
5887
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overw_bg,f))
5888 {
5889 return qe_invalid;
5890 }
5891
5892
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5893 {
5894 return qe_invalid;
5895 }
5896
5897
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5898 {
5899 return qe_invalid;
5900 }
5901
5902
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.cave_fg,f))
5903 {
5904 return qe_invalid;
5905 }
5906
5907
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_dk,f))
5908 {
5909 return qe_invalid;
5910 }
5911
5912
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_goal,f))
5913 {
5914 return qe_invalid;
5915 }
5916
5917
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_lt,f))
5918 {
5919 return qe_invalid;
5920 }
5921
5922
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_dk,f))
5923 {
5924 return qe_invalid;
5925 }
5926
5927
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5928 {
5929 return qe_invalid;
5930 }
5931
5932
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_color,f))
5933 {
5934 return qe_invalid;
5935 }
5936
5937
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.hero_dot,f))
5938 {
5939 return qe_invalid;
5940 }
5941
5942
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5943 {
5944 return qe_invalid;
5945 }
5946
5947
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5948 {
5949 return qe_invalid;
5950 }
5951
5952
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5953 {
5954 return qe_invalid;
5955 }
5956
5957
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5958 {
5959 return qe_invalid;
5960 }
5961
5962
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5963 {
5964 return qe_invalid;
5965 }
5966
5967
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5968 {
5969 return qe_invalid;
5970 }
5971
5972
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5973 {
5974 return qe_invalid;
5975 }
5976
5977
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
5978 {
5979 return qe_invalid;
5980 }
5981
5982
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
5983 {
5984 return qe_invalid;
5985 }
5986
5987
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
5988 {
5989 return qe_invalid;
5990 }
5991
5992
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
5993 {
5994 return qe_invalid;
5995 }
5996
5997
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
5998 {
5999 return qe_invalid;
6000 }
6001
6002
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
6003 {
6004 return qe_invalid;
6005 }
6006
6007
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
6008 {
6009 return qe_invalid;
6010 }
6011
6012 16 temp_misc.colors.msgtext = 0x01;
6013
6014
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(Header->zelda_version < 0x193)
6015 {
6016
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
32 for(int32_t i=0; i<7; i++)
6017 {
6018
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&tempbyte,f))
6019 {
6020 return qe_invalid;
6021 }
6022 28 }
6023 4 }
6024
6025
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version == 0x192)&&(Header->build>145))
6026 {
6027 for(int32_t i=0; i<256; i++)
6028 {
6029 if(!p_getc(&tempbyte,f))
6030 {
6031 return qe_invalid;
6032 }
6033 }
6034 }
6035
6036
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(s_version>1)
6037 {
6038 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6039 {
6040 return qe_invalid;
6041 }
6042 }
6043
6044 //save game icons
6045
2/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version < 0x192)||
6046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6047 {
6048 4 icons=3;
6049 4 }
6050
6051
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 16 times.
76 for(int32_t i=0; i<icons; i++)
6052 {
6053
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&temp_misc.icons[i],f))
6054 {
6055 return qe_invalid;
6056 }
6057 60 }
6058 16 }
6059
6060
2/4
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
130 if((Header->zelda_version < 0x192)||
6061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6062 {
6063 4 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6064
6065 4 return 0;
6066 }
6067
6068 //pond information
6069
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(Header->zelda_version < 0x193)
6070 {
6071 if((Header->zelda_version == 0x192)&&(Header->build<146))
6072 {
6073 pondsize=25;
6074 }
6075
6076 for(int32_t i=0; i<ponds; i++)
6077 {
6078 for(int32_t j=0; j<pondsize; j++)
6079 {
6080 if(!p_getc(&tempbyte,f))
6081 {
6082 return qe_invalid;
6083
6084 }
6085 }
6086 }
6087 }
6088
6089 //end string
6090
1/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if((Header->zelda_version < 0x192)||
6091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6092 {
6093 if(!p_getc(&tempbyte,f))
6094 {
6095 return qe_invalid;
6096 }
6097
6098 temp_misc.endstring=tempbyte;
6099
6100 if(!p_getc(&tempbyte,f))
6101 {
6102 return qe_invalid;
6103 }
6104 }
6105 else
6106 {
6107
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&temp_misc.endstring,f))
6108 {
6109 return qe_invalid;
6110 }
6111 }
6112
6113 //expansion
6114
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(Header->zelda_version < 0x193)
6115 {
6116 if((Header->zelda_version == 0x192)&&(Header->build<73))
6117 {
6118 expansionsize=99*2;
6119 }
6120
6121 for(int32_t i=0; i<expansionsize; i++)
6122 {
6123 if(!p_getc(&tempbyte,f))
6124 {
6125 return qe_invalid;
6126 }
6127 }
6128 }
6129 //shops v8
6130
6131
6132
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 37 times.
126 if(s_version >= 8)
6133 {
6134
2/2
✓ Branch 0 taken 544 times.
✓ Branch 1 taken 37 times.
581 for(int32_t i=0; i<shops; i++)
6135 {
6136
2/2
✓ Branch 0 taken 1632 times.
✓ Branch 1 taken 544 times.
2176 for(int32_t j=0; j<3; j++)
6137 {
6138
1/2
✓ Branch 0 taken 1632 times.
✗ Branch 1 not taken.
1632 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6139 return qe_invalid;
6140 1632 }
6141 544 }
6142 37 }
6143
6144 126 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6145 126 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6146 126 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6147
6148 //v9 includes quest misc[32]
6149
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 37 times.
126 if(s_version >= 9)
6150 {
6151
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 37 times.
1221 for ( int32_t q = 0; q < 32; q++ )
6152 {
6153
1/2
✓ Branch 0 taken 1184 times.
✗ Branch 1 not taken.
1184 if(!p_igetl(&temp_misc.questmisc[q],f))
6154 return qe_invalid;
6155 1184 }
6156
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 37 times.
1221 for ( int32_t q = 0; q < 32; q++ )
6157 {
6158
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 1184 times.
152736 for ( int32_t j = 0; j < 128; j++ )
6159
1/2
✓ Branch 0 taken 151552 times.
✗ Branch 1 not taken.
151552 if(!p_getc(&temp_misc.questmisc_strings[q][j],f))
6160 return qe_invalid;
6161 1184 }
6162 37 }
6163
6164
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if(s_version >= 11 )
6165 {
6166
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6167 return qe_invalid;
6168 37 }
6169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(s_version < 11 )
6170 {
6171 89 temp_misc.zscript_last_compiled_version = -1;
6172 89 }
6173
6174 126 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6175
6176
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if(s_version >= 12)
6177 {
6178 byte spr;
6179
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 37 times.
9509 for(int32_t q = 0; q < sprMAX; ++q)
6180 {
6181
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_getc(&spr,f))
6182 return qe_invalid;
6183 9472 temp_misc.sprites[q] = spr;
6184 9472 }
6185 37 }
6186 else
6187 {
6188 89 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6189 //temp_misc.sprites[sprFALL] = ;
6190 }
6191
6192
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if(s_version >= 13)
6193 {
6194
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 37 times.
2405 for(size_t q = 0; q < 64; ++q)
6195 {
6196 2368 bottletype* bt = &(temp_misc.bottle_types[q]);
6197
1/2
✓ Branch 0 taken 2368 times.
✗ Branch 1 not taken.
2368 if (!pfread(bt->name, 32, f))
6198 return qe_invalid;
6199
2/2
✓ Branch 0 taken 7104 times.
✓ Branch 1 taken 2368 times.
9472 for(size_t j = 0; j < 3; ++j)
6200 {
6201
1/2
✓ Branch 0 taken 7104 times.
✗ Branch 1 not taken.
7104 if (!p_getc(&(bt->counter[j]), f))
6202 return qe_invalid;
6203
1/2
✓ Branch 0 taken 7104 times.
✗ Branch 1 not taken.
7104 if (!p_igetw(&(bt->amount[j]), f))
6204 return qe_invalid;
6205 7104 }
6206
1/2
✓ Branch 0 taken 2368 times.
✗ Branch 1 not taken.
2368 if (!p_getc(&(bt->flags), f))
6207 return qe_invalid;
6208
1/2
✓ Branch 0 taken 2368 times.
✗ Branch 1 not taken.
2368 if (!p_getc(&(bt->next_type), f))
6209 return qe_invalid;
6210 2368 }
6211
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 37 times.
9509 for(size_t q = 0; q < 256; ++q)
6212 {
6213 9472 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6214
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if (!pfread(bst->name, 32, f))
6215 return qe_invalid;
6216
2/2
✓ Branch 0 taken 28416 times.
✓ Branch 1 taken 9472 times.
37888 for(size_t j = 0; j < 3; ++j)
6217 {
6218
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if (!p_getc(&(bst->fill[j]), f))
6219 return qe_invalid;
6220
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if (!p_igetw(&(bst->comb[j]), f))
6221 return qe_invalid;
6222
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if (!p_getc(&(bst->cset[j]), f))
6223 return qe_invalid;
6224
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if (!p_igetw(&(bst->price[j]), f))
6225 return qe_invalid;
6226
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if (!p_igetw(&(bst->str[j]), f))
6227 return qe_invalid;
6228 28416 }
6229 9472 }
6230 37 }
6231 else
6232 {
6233
2/2
✓ Branch 0 taken 5696 times.
✓ Branch 1 taken 89 times.
5785 for(size_t q = 0; q < 64; ++q)
6234 5696 temp_misc.bottle_types[q].clear();
6235
2/2
✓ Branch 0 taken 22784 times.
✓ Branch 1 taken 89 times.
22873 for(size_t q = 0; q < 256; ++q)
6236 22784 temp_misc.bottle_shop_types[q].clear();
6237 }
6238
6239
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if(s_version >= 14)
6240 {
6241 byte msfx;
6242
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 37 times.
9509 for(int32_t q = 0; q < sfxMAX; ++q)
6243 {
6244
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_getc(&msfx,f))
6245 return qe_invalid;
6246 9472 temp_misc.miscsfx[q] = msfx;
6247 9472 }
6248 37 }
6249 else
6250 {
6251 89 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6252 89 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6253 89 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6254 }
6255
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if(s_version < 15)
6256 {
6257 89 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6258 89 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6259 89 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6260 89 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6261 89 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6262 89 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6263 89 }
6264
6265 126 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6266
6267 126 return 0;
6268 130 }
6269
6270 extern char *item_string[MAXITEMS];
6271 extern const char *old_item_string[iLast];
6272 extern char *weapon_string[MAXWPNS];
6273 extern const char *old_weapon_string[wLast];
6274
6275 130 int32_t readitems(PACKFILE *f, word version, word build)
6276 {
6277 byte padding;
6278 int32_t dummy;
6279 130 word items_to_read=MAXITEMS;
6280 itemdata tempitem;
6281 130 word s_version=0, s_cversion=0;
6282 word dummy_word;
6283
6284
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(version < 0x186)
6285 {
6286 items_to_read=64;
6287 }
6288
6289
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(version > 0x192)
6290 {
6291 126 items_to_read=0;
6292
6293 //section version info
6294
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_version,f))
6295 {
6296 return qe_invalid;
6297 }
6298
6299 126 FFCore.quest_format[vItems] = s_version;
6300
6301 //al_trace("Items version %d\n", s_version);
6302
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_cversion,f))
6303 {
6304 return qe_invalid;
6305 }
6306
6307 //section size
6308
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy,f))
6309 {
6310 return qe_invalid;
6311 }
6312
6313 //finally... section data
6314
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&items_to_read,f))
6315 {
6316 return qe_invalid;
6317 }
6318
6319
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 if (!(items_to_read >= 0 && items_to_read <= MAXITEMS))
6320 {
6321 return qe_invalid;
6322 }
6323 126 }
6324
6325
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version>1)
6326 {
6327
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<items_to_read; i++)
6328 {
6329 char tempname[64];
6330
6331
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!pfread(tempname, 64, f))
6332 {
6333 return qe_invalid;
6334 }
6335
6336 29184 item_string[i][0] = '\0';
6337 29184 strncat(item_string[i], tempname, 64 - 1);
6338 29184 }
6339 114 }
6340 else
6341 {
6342
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
6343 {
6344 4096 reset_itemname(i);
6345 4096 }
6346 }
6347
6348
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<MAXITEMS; i++)
6349 {
6350 33280 itemdata& id = itemsbuf[i];
6351 33280 memset(&id, 0, sizeof(itemdata));
6352 33280 id.count=-1;
6353 33280 id.playsound=WAV_SCALE;
6354 33280 reset_itembuf(&id,i);
6355 33280 }
6356
6357
2/2
✓ Branch 0 taken 31048 times.
✓ Branch 1 taken 130 times.
31178 for(int32_t i=0; i<items_to_read; i++)
6358 {
6359 31048 memset(&tempitem, 0, sizeof(itemdata));
6360 31048 reset_itembuf(&tempitem,i);
6361
6362
6363
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 21576 times.
31048 if ( s_version > 35 ) //expanded tiles
6364 {
6365
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.tile,f))
6366 {
6367 return qe_invalid;
6368 }
6369 9472 }
6370 else
6371 {
6372
1/2
✓ Branch 0 taken 21576 times.
✗ Branch 1 not taken.
21576 if(!p_igetw(&tempitem.tile,f))
6373 {
6374 return qe_invalid;
6375 }
6376 }
6377
6378
1/2
✓ Branch 0 taken 31048 times.
✗ Branch 1 not taken.
31048 if(!p_getc(&tempitem.misc_flags,f))
6379 {
6380 return qe_invalid;
6381 }
6382
6383
1/2
✓ Branch 0 taken 31048 times.
✗ Branch 1 not taken.
31048 if(!p_getc(&tempitem.csets,f))
6384 {
6385 return qe_invalid;
6386 }
6387
6388
1/2
✓ Branch 0 taken 31048 times.
✗ Branch 1 not taken.
31048 if(!p_getc(&tempitem.frames,f))
6389 {
6390 return qe_invalid;
6391 }
6392
6393
1/2
✓ Branch 0 taken 31048 times.
✗ Branch 1 not taken.
31048 if(!p_getc(&tempitem.speed,f))
6394 {
6395 return qe_invalid;
6396 }
6397
6398
1/2
✓ Branch 0 taken 31048 times.
✗ Branch 1 not taken.
31048 if(!p_getc(&tempitem.delay,f))
6399 {
6400 return qe_invalid;
6401 }
6402
6403
2/2
✓ Branch 0 taken 30024 times.
✓ Branch 1 taken 1024 times.
31048 if(version < 0x193)
6404 {
6405
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
6406 {
6407 return qe_invalid;
6408 }
6409
6410
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1024 if((version < 0x192)||((version == 0x192)&&(build<186)))
6411 {
6412
3/3
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
1024 switch(i)
6413 {
6414 case iShield:
6415 4 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6416 4 break;
6417
6418 case iMShield:
6419 4 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6420 4 break;
6421
6422 default:
6423 1016 tempitem.ltm=0;
6424 1016 break;
6425 }
6426
6427 1024 tempitem.count=-1;
6428 1024 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6429 1024 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6430 1024 tempitem.family=0xFF;
6431 1024 tempitem.playsound=WAV_SCALE;
6432 1024 reset_itembuf(&tempitem,i);
6433
6434 1024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6435
6436 1024 continue;
6437 }
6438 }
6439
6440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30024 times.
30024 if(!p_igetl(&tempitem.ltm,f))
6441 {
6442 return qe_invalid;
6443 }
6444
6445
1/2
✓ Branch 0 taken 30024 times.
✗ Branch 1 not taken.
30024 if(version < 0x193)
6446 {
6447 for(int32_t q=0; q<12; q++)
6448 {
6449 if(!p_getc(&padding,f))
6450 {
6451 return qe_invalid;
6452 }
6453 }
6454 }
6455
6456
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 840 times.
30024 if(s_version>1)
6457 {
6458
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 19712 times.
29184 if ( s_version >= 31 )
6459 {
6460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.family,f))
6461 {
6462 return qe_invalid;
6463 }
6464 9472 }
6465 else
6466 {
6467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.family,f))
6468 {
6469 return qe_invalid;
6470 }
6471 }
6472
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(s_version < 16)
6473 if(tempitem.family == 0xFF)
6474 tempitem.family = itype_misc;
6475
6476
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.fam_type,f))
6477 {
6478 return qe_invalid;
6479 }
6480
6481
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(s_version>5)
6482 {
6483
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 19712 times.
29184 if(s_version>=31)
6484 {
6485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.power,f))
6486 {
6487 return qe_invalid;
6488 }
6489 9472 }
6490 else
6491 {
6492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.power,f))
6493 {
6494 return qe_invalid;
6495 }
6496 }
6497
6498 //converted flags from 16b to 32b -Z
6499
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version < 41 )
6500 {
6501
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_igetw(&tempitem.flags,f))
6502 {
6503 return qe_invalid;
6504 }
6505 19712 }
6506 else
6507 {
6508
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.flags,f))
6509 {
6510 return qe_invalid;
6511 }
6512 }
6513 29184 }
6514 else
6515 {
6516 //tempitem.power = tempitem.fam_type;
6517 char tempchar;
6518
6519 if(!p_getc(&tempchar,f))
6520 {
6521 return qe_invalid;
6522 }
6523
6524 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6525 }
6526
6527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_igetw(&tempitem.script,f))
6528 {
6529 return qe_invalid;
6530 }
6531
6532
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(s_version<=3)
6533 {
6534 if(tempitem.script > NUMSCRIPTITEM)
6535 {
6536 tempitem.script = 0;
6537 }
6538 }
6539
6540
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.count,f))
6541 {
6542 return qe_invalid;
6543 }
6544
6545
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_igetw(&tempitem.amount,f))
6546 {
6547 return qe_invalid;
6548 }
6549
6550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_igetw(&tempitem.collect_script,f))
6551 {
6552 return qe_invalid;
6553 }
6554
6555
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(s_version<=3)
6556 {
6557 if(tempitem.collect_script > NUMSCRIPTITEM)
6558 {
6559 tempitem.collect_script = 0;
6560 }
6561 }
6562
6563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_igetw(&tempitem.setmax,f))
6564 {
6565 return qe_invalid;
6566 }
6567
6568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_igetw(&tempitem.max,f))
6569 {
6570 return qe_invalid;
6571 }
6572
6573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_getc(&tempitem.playsound,f))
6574 {
6575 return qe_invalid;
6576 }
6577
6578
2/2
✓ Branch 0 taken 233472 times.
✓ Branch 1 taken 29184 times.
262656 for(int32_t j=0; j<8; j++)
6579 {
6580
1/2
✓ Branch 0 taken 233472 times.
✗ Branch 1 not taken.
233472 if(!p_igetl(&tempitem.initiald[j],f))
6581 {
6582 return qe_invalid;
6583 }
6584 233472 }
6585
6586
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 29184 times.
87552 for(int32_t j=0; j<2; j++)
6587 {
6588
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&tempitem.initiala[j],f))
6589 {
6590 return qe_invalid;
6591 }
6592 58368 }
6593
6594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(s_version>4)
6595 {
6596
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(s_version>5)
6597 {
6598
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.wpn,f))
6599 {
6600 return qe_invalid;
6601 }
6602
6603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_getc(&tempitem.wpn2,f))
6604 {
6605 return qe_invalid;
6606 }
6607
6608
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.wpn3,f))
6609 {
6610 return qe_invalid;
6611 }
6612
6613
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.wpn4,f))
6614 {
6615 return qe_invalid;
6616 }
6617
6618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(s_version>=15)
6619 {
6620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_getc(&tempitem.wpn5,f))
6621 {
6622 return qe_invalid;
6623 }
6624
6625
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.wpn6,f))
6626 {
6627 return qe_invalid;
6628 }
6629
6630
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.wpn7,f))
6631 {
6632 return qe_invalid;
6633 }
6634
6635
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.wpn8,f))
6636 {
6637 return qe_invalid;
6638 }
6639
6640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_getc(&tempitem.wpn9,f))
6641 {
6642 return qe_invalid;
6643 }
6644
6645
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.wpn10,f))
6646 {
6647 return qe_invalid;
6648 }
6649 29184 }
6650
6651
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.pickup_hearts,f))
6652 {
6653 return qe_invalid;
6654 }
6655
6656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(s_version<15)
6657 {
6658 if(!p_igetw(&dummy_word,f))
6659 {
6660 return qe_invalid;
6661 }
6662
6663 tempitem.misc1=dummy_word;
6664
6665 if(!p_igetw(&dummy_word,f))
6666 {
6667 return qe_invalid;
6668 }
6669
6670 tempitem.misc2=dummy_word;
6671 }
6672 else
6673 {
6674
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_igetl(&tempitem.misc1,f))
6675 {
6676 return qe_invalid;
6677 }
6678
6679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_igetl(&tempitem.misc2,f))
6680 {
6681 return qe_invalid;
6682 }
6683
6684 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6685
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(s_version<24)
6686 {
6687 if(tempitem.family==itype_shield)
6688 {
6689 tempitem.misc1|=shSCRIPT;
6690 }
6691 }
6692 }
6693
6694
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if(s_version < 53)
6695 {
6696 byte tempbyte;
6697
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_getc(&tempbyte,f))
6698 {
6699 return qe_invalid;
6700 }
6701 19712 tempitem.cost_amount[0] = tempbyte;
6702 19712 }
6703 else
6704 {
6705
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 9472 times.
28416 for(auto q = 0; q < 2; ++q)
6706 {
6707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18944 times.
18944 if(!p_igetw(&tempitem.cost_amount[q],f))
6708 {
6709 return qe_invalid;
6710 }
6711 18944 }
6712 }
6713 29184 }
6714 else
6715 {
6716 char tempchar;
6717
6718 if(!p_getc(&tempchar,f))
6719 {
6720 return qe_invalid;
6721 }
6722
6723 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6724 }
6725
6726 // June 2007: more misc. attributes
6727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(s_version>=12)
6728 {
6729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(s_version<15)
6730 {
6731 if(!p_igetw(&dummy_word,f))
6732 {
6733 return qe_invalid;
6734 }
6735
6736 tempitem.misc3=dummy_word;
6737
6738 if(!p_igetw(&dummy_word,f))
6739 {
6740 return qe_invalid;
6741 }
6742
6743 tempitem.misc4=dummy_word;
6744 }
6745 else
6746 {
6747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_igetl(&tempitem.misc3,f))
6748 {
6749 return qe_invalid;
6750 }
6751
6752
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_igetl(&tempitem.misc4,f))
6753 {
6754 return qe_invalid;
6755 }
6756
6757
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_igetl(&tempitem.misc5,f))
6758 {
6759 return qe_invalid;
6760 }
6761
6762
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_igetl(&tempitem.misc6,f))
6763 {
6764 return qe_invalid;
6765 }
6766
6767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_igetl(&tempitem.misc7,f))
6768 {
6769 return qe_invalid;
6770 }
6771
6772
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_igetl(&tempitem.misc8,f))
6773 {
6774 return qe_invalid;
6775 }
6776
6777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_igetl(&tempitem.misc9,f))
6778 {
6779 return qe_invalid;
6780 }
6781
6782
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_igetl(&tempitem.misc10,f))
6783 {
6784 return qe_invalid;
6785 }
6786 }
6787
6788
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.usesound,f))
6789 {
6790 return qe_invalid;
6791 }
6792
6793
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 19712 times.
29184 if(s_version >= 49)
6794 {
6795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_getc(&tempitem.usesound2,f))
6796 {
6797 return qe_invalid;
6798 }
6799 9472 }
6800 19712 else tempitem.usesound2 = 0;
6801
6802
3/4
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
✓ Branch 2 taken 19712 times.
✗ Branch 3 not taken.
29184 if(s_version < 50 && tempitem.family == itype_mirror)
6803 {
6804 //Split continue/dmap warp effect/sfx, port for old
6805 tempitem.misc2 = tempitem.misc1;
6806 tempitem.usesound2 = tempitem.usesound;
6807 }
6808 29184 }
6809 29184 }
6810
6811
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6812 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_getc(&tempitem.useweapon,f))
6814 {
6815 return qe_invalid;
6816 }
6817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_getc(&tempitem.usedefence,f))
6818 {
6819 return qe_invalid;
6820 }
6821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.weaprange,f))
6822 {
6823 return qe_invalid;
6824 }
6825
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.weapduration,f))
6826 {
6827 return qe_invalid;
6828 }
6829
2/2
✓ Branch 0 taken 94720 times.
✓ Branch 1 taken 9472 times.
104192 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6830 {
6831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94720 times.
94720 if(!p_igetl(&tempitem.weap_pattern[q],f))
6832 {
6833 return qe_invalid;
6834 }
6835 94720 }
6836 9472 }
6837
6838
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6839 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6840
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.duplicates,f))
6841 {
6842 return qe_invalid;
6843 }
6844
2/2
✓ Branch 0 taken 75776 times.
✓ Branch 1 taken 9472 times.
85248 for ( int32_t q = 0; q < INITIAL_D; q++ )
6845 {
6846
1/2
✓ Branch 0 taken 75776 times.
✗ Branch 1 not taken.
75776 if(!p_igetl(&tempitem.weap_initiald[q],f))
6847 {
6848 return qe_invalid;
6849 }
6850 75776 }
6851
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 9472 times.
28416 for ( int32_t q = 0; q < INITIAL_A; q++ )
6852 {
6853
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&tempitem.weap_initiala[q],f))
6854 {
6855 return qe_invalid;
6856 }
6857 18944 }
6858
6859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_getc(&tempitem.drawlayer,f))
6860 {
6861 return qe_invalid;
6862 }
6863
6864
6865
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.hxofs,f))
6866 {
6867 return qe_invalid;
6868 }
6869
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.hyofs,f))
6870 {
6871 return qe_invalid;
6872 }
6873
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.hxsz,f))
6874 {
6875 return qe_invalid;
6876 }
6877
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.hysz,f))
6878 {
6879 return qe_invalid;
6880 }
6881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.hzsz,f))
6882 {
6883 return qe_invalid;
6884 }
6885
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.xofs,f))
6886 {
6887 return qe_invalid;
6888 }
6889
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.yofs,f))
6890 {
6891 return qe_invalid;
6892 }
6893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.weap_hxofs,f))
6894 {
6895 return qe_invalid;
6896 }
6897
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.weap_hyofs,f))
6898 {
6899 return qe_invalid;
6900 }
6901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.weap_hxsz,f))
6902 {
6903 return qe_invalid;
6904 }
6905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.weap_hysz,f))
6906 {
6907 return qe_invalid;
6908 }
6909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.weap_hzsz,f))
6910 {
6911 return qe_invalid;
6912 }
6913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.weap_xofs,f))
6914 {
6915 return qe_invalid;
6916 }
6917
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.weap_yofs,f))
6918 {
6919 return qe_invalid;
6920 }
6921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetw(&tempitem.weaponscript,f))
6922 {
6923 return qe_invalid;
6924 }
6925
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.wpnsprite,f))
6926 {
6927 return qe_invalid;
6928 }
6929 9472 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6930
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 9472 times.
28416 for(auto q = 0; q < num_cost_tmr; ++q)
6931 {
6932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18944 times.
18944 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6933 {
6934 return qe_invalid;
6935 }
6936 18944 }
6937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 for(auto q = num_cost_tmr; q < 2; ++q)
6938 tempitem.magiccosttimer[q] = 0;
6939 9472 }
6940
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6941 {
6942 //Item Size FLags, TileWidth, TileHeight
6943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.overrideFLAGS,f))
6944 {
6945 return qe_invalid;
6946 }
6947
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.tilew,f))
6948 {
6949 return qe_invalid;
6950 }
6951
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.tileh,f))
6952 {
6953 return qe_invalid;
6954 }
6955 9472 }
6956
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 29 ) //! More new vars.
6957 {
6958 //Item Size FLags, TileWidth, TileHeight
6959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
6960 {
6961 return qe_invalid;
6962 }
6963
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.weap_tilew,f))
6964 {
6965 return qe_invalid;
6966 }
6967
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.weap_tileh,f))
6968 {
6969 return qe_invalid;
6970 }
6971 9472 }
6972
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 30 ) //! More new vars.
6973 {
6974 //Pickup Type
6975
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.pickup,f))
6976 {
6977 return qe_invalid;
6978 }
6979 9472 }
6980
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 32 ) //! More new vars.
6981 {
6982 //Pickup Type
6983
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetw(&tempitem.pstring,f))
6984 {
6985 return qe_invalid;
6986 }
6987 9472 }
6988
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 33 ) //! More new vars.
6989 {
6990 //Pickup Type
6991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetw(&tempitem.pickup_string_flags,f))
6992 {
6993 return qe_invalid;
6994 }
6995 9472 }
6996
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 34 ) //! cost counter
6997 {
6998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(s_version < 53)
6999 {
7000 if(!p_getc(&tempitem.cost_counter[0],f))
7001 {
7002 return qe_invalid;
7003 }
7004 }
7005 else
7006 {
7007
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 9472 times.
28416 for(auto q = 0; q < 2; ++q)
7008 {
7009
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&tempitem.cost_counter[q],f))
7010 {
7011 return qe_invalid;
7012 }
7013 18944 }
7014 }
7015 9472 }
7016
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 44 ) //! sprite scripts
7017 {
7018
2/2
✓ Branch 0 taken 75776 times.
✓ Branch 1 taken 9472 times.
85248 for ( int32_t q = 0; q < 8; q++ )
7019 {
7020
2/2
✓ Branch 0 taken 4925440 times.
✓ Branch 1 taken 75776 times.
5001216 for ( int32_t w = 0; w < 65; w++ )
7021 {
7022
1/2
✓ Branch 0 taken 4925440 times.
✗ Branch 1 not taken.
4925440 if(!p_getc(&(tempitem.initD_label[q][w]),f))
7023 {
7024 return qe_invalid;
7025 }
7026 4925440 }
7027
2/2
✓ Branch 0 taken 4925440 times.
✓ Branch 1 taken 75776 times.
5001216 for ( int32_t w = 0; w < 65; w++ )
7028 {
7029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4925440 times.
4925440 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
7030 {
7031 return qe_invalid;
7032 }
7033 4925440 }
7034
2/2
✓ Branch 0 taken 4925440 times.
✓ Branch 1 taken 75776 times.
5001216 for ( int32_t w = 0; w < 65; w++ )
7035 {
7036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4925440 times.
4925440 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7037 {
7038 return qe_invalid;
7039 }
7040 4925440 }
7041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75776 times.
75776 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7042 {
7043 return qe_invalid;
7044 }
7045
7046 75776 }
7047
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 9472 times.
28416 for ( int32_t q = 0; q < 2; q++ )
7048 {
7049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18944 times.
18944 if(!p_getc(&(tempitem.sprite_initiala[q]),f))
7050 {
7051 return qe_invalid;
7052 }
7053 18944 }
7054 //Pickup Type
7055
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetw(&tempitem.sprite_script,f))
7056 {
7057 return qe_invalid;
7058 }
7059 9472 }
7060
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 48 ) //! pickup flags
7061 {
7062
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_getc(&(tempitem.pickupflag),f))
7063 {
7064 return qe_invalid;
7065 }
7066 9472 }
7067
2/2
✓ Branch 0 taken 21248 times.
✓ Branch 1 taken 7936 times.
29184 if ( s_version >= 57 )
7068 {
7069 7936 std::string str;
7070
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7936 times.
✓ Branch 2 taken 7936 times.
✗ Branch 3 not taken.
7936 if(!p_getcstr(&str,f))
7071 return qe_invalid;
7072 7936 strncpy(tempitem.display_name,str.c_str(),255);
7073
1/3
✓ Branch 0 taken 7936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
7936 }
7074 29184 }
7075 else
7076 {
7077 840 tempitem.count=-1;
7078 840 tempitem.family=itype_misc;
7079 840 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7080 840 tempitem.playsound=WAV_SCALE;
7081 840 reset_itembuf(&tempitem,i);
7082 }
7083
7084 30024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7085 30024 }
7086
7087 //////////////////////////////////////////////////////
7088 // Now do any updates because of new item additions
7089 // (These can't be done above because items_to_read
7090 // might be too low.)
7091 //////////////////////////////////////////////////////
7092
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<MAXITEMS; i++)
7093 {
7094 33280 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7095
7096 //Account for older quests that didn't have an actual item for the used letter
7097
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 29184 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33280 if(s_version < 2 && i==iLetterUsed)
7098 {
7099 16 reset_itembuf(&tempitem, iLetterUsed);
7100 16 strcpy(item_string[i],old_item_string[i]);
7101 16 tempitem.tile = itemsbuf[iLetter].tile;
7102 16 tempitem.csets = itemsbuf[iLetter].csets;
7103 16 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7104 16 tempitem.frames = itemsbuf[iLetter].frames;
7105 16 tempitem.speed = itemsbuf[iLetter].speed;
7106 16 tempitem.ltm = itemsbuf[iLetter].ltm;
7107 16 }
7108
7109
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 3)
7110 {
7111
3/3
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 3728 times.
✓ Branch 2 taken 16 times.
4096 switch(i)
7112 {
7113 case iRocsFeather:
7114 case iHoverBoots:
7115 case iSpinScroll:
7116 case iL2SpinScroll:
7117 case iCrossScroll:
7118 case iQuakeScroll:
7119 case iL2QuakeScroll:
7120 case iWhispRing:
7121 case iL2WhispRing:
7122 case iChargeRing:
7123 case iL2ChargeRing:
7124 case iPerilScroll:
7125 case iWalletL3:
7126 case iQuiverL4:
7127 case iBombBagL4:
7128 case iBracelet:
7129 case iL2Bracelet:
7130 case iOldGlove:
7131 case iL2Ladder:
7132 case iWealthMedal:
7133 case iL2WealthMedal:
7134 case iL3WealthMedal:
7135 352 reset_itembuf(&tempitem, i);
7136 352 strcpy(item_string[i],old_item_string[i]);
7137 352 break;
7138
7139 case iSShield:
7140 16 reset_itembuf(&tempitem, i);
7141 16 strcpy(item_string[i],old_item_string[i]);
7142 16 strcpy(item_string[iShield],old_item_string[iShield]);
7143 16 strcpy(item_string[iMShield],old_item_string[iMShield]);
7144 16 break;
7145 }
7146 4096 }
7147
7148
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 5)
7149 {
7150
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3984 times.
4096 switch(i)
7151 {
7152 case iHeartRing:
7153 case iL2HeartRing:
7154 case iL3HeartRing:
7155 case iMagicRing:
7156 case iL2MagicRing:
7157 case iL3MagicRing:
7158 case iL4MagicRing:
7159 112 reset_itembuf(&tempitem, i);
7160 112 strcpy(item_string[i],old_item_string[i]);
7161 112 break;
7162 }
7163 4096 }
7164
7165
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7166 {
7167
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(i!=iBPotion && i!=iRPotion)
7168 4064 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7169
7170
43/43
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 16 times.
✓ Branch 15 taken 16 times.
✓ Branch 16 taken 16 times.
✓ Branch 17 taken 16 times.
✓ Branch 18 taken 16 times.
✓ Branch 19 taken 16 times.
✓ Branch 20 taken 16 times.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 64 times.
✓ Branch 23 taken 3376 times.
✓ Branch 24 taken 16 times.
✓ Branch 25 taken 16 times.
✓ Branch 26 taken 16 times.
✓ Branch 27 taken 16 times.
✓ Branch 28 taken 16 times.
✓ Branch 29 taken 16 times.
✓ Branch 30 taken 16 times.
✓ Branch 31 taken 16 times.
✓ Branch 32 taken 16 times.
✓ Branch 33 taken 16 times.
✓ Branch 34 taken 16 times.
✓ Branch 35 taken 16 times.
✓ Branch 36 taken 16 times.
✓ Branch 37 taken 16 times.
✓ Branch 38 taken 16 times.
✓ Branch 39 taken 16 times.
✓ Branch 40 taken 16 times.
✓ Branch 41 taken 16 times.
✓ Branch 42 taken 16 times.
4096 switch(i)
7171 {
7172 case iTriforce:
7173 16 tempitem.fam_type=1;
7174 16 break;
7175
7176 case iBigTri:
7177 16 tempitem.fam_type=0;
7178 16 break;
7179
7180 case iBombs:
7181 16 tempitem.fam_type=i_bomb;
7182 16 tempitem.power=4;
7183 16 tempitem.wpn=wBOMB;
7184 16 tempitem.wpn2=wBOOM;
7185 16 tempitem.misc1 = 50;
7186
7187
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7188
7189 16 break;
7190
7191 case iSBomb:
7192 16 tempitem.fam_type=i_sbomb;
7193 16 tempitem.power=16;
7194 16 tempitem.wpn=wSBOMB;
7195 16 tempitem.wpn2=wSBOOM;
7196 16 tempitem.misc1 = 50;
7197
7198
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7199
7200 16 break;
7201
7202 case iBook:
7203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7204 tempitem.wpn = wFIREMAGIC;
7205
7206 16 break;
7207
7208 case iSArrow:
7209 16 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7210 16 tempitem.power=4;
7211 16 tempitem.flags|=ITEM_GAMEDATA;
7212 16 tempitem.wpn=wSARROW;
7213 16 break;
7214
7215 case iGArrow:
7216 16 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7217 16 tempitem.power=8;
7218 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7219 16 tempitem.wpn=wGARROW;
7220 16 break;
7221
7222 case iBrang:
7223 16 tempitem.power=0;
7224 16 tempitem.wpn=wBRANG;
7225 16 tempitem.misc1=36;
7226 16 break;
7227
7228 case iMBrang:
7229 16 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7230 16 tempitem.power=0;
7231 16 tempitem.wpn=wMBRANG;
7232 16 break;
7233
7234 case iFBrang:
7235 16 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7236 16 tempitem.power=2;
7237 16 tempitem.wpn=wFBRANG;
7238 16 break;
7239
7240 case iBoots:
7241 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7242 16 tempitem.power=7;
7243 16 break;
7244
7245 case iWand:
7246 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7247 16 tempitem.power=2;
7248 16 tempitem.wpn=wWAND;
7249 16 tempitem.wpn3=wMAGIC;
7250 16 break;
7251
7252 case iBCandle:
7253 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7254 16 tempitem.power=1;
7255 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7256 16 tempitem.wpn3=wFIRE;
7257 16 break;
7258
7259 case iRCandle:
7260 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7261 16 tempitem.power=1;
7262 16 tempitem.wpn3=wFIRE;
7263 16 break;
7264
7265 case iSword:
7266 16 tempitem.power=1;
7267 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7268 16 tempitem.wpn=tempitem.wpn3=wSWORD;
7269 16 tempitem.wpn2=wSWORDSLASH;
7270 16 break;
7271
7272 case iWSword:
7273 16 tempitem.power=2;
7274 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7275 16 tempitem.wpn=tempitem.wpn3=wWSWORD;
7276 16 tempitem.wpn2=wWSWORDSLASH;
7277 16 break;
7278
7279 case iMSword:
7280 16 tempitem.power=4;
7281 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7282 16 tempitem.wpn=tempitem.wpn3=wMSWORD;
7283 16 tempitem.wpn2=wMSWORDSLASH;
7284 16 break;
7285
7286 case iXSword:
7287 16 tempitem.power=8;
7288 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7289 16 tempitem.wpn=tempitem.wpn3=wXSWORD;
7290 16 tempitem.wpn2=wXSWORDSLASH;
7291 16 break;
7292
7293 case iDivineProtection:
7294 16 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG1 : 0;
7295 16 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG2 : 0;
7296 16 tempitem.wpn=wDIVINEPROTECTION1A;
7297 16 tempitem.wpn2=wDIVINEPROTECTION1B;
7298 16 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7299 16 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7300 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7301 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7302 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7303 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7304 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7305 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7306 16 tempitem.misc1=512;
7307 16 tempitem.cost_amount[0]=64;
7308 16 break;
7309
7310 case iLens:
7311 16 tempitem.misc1=60;
7312 16 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7313 16 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7314 16 break;
7315
7316 case iArrow:
7317 16 tempitem.power=2;
7318 16 tempitem.wpn=wARROW;
7319 16 break;
7320
7321 case iHoverBoots:
7322 16 tempitem.misc1=45;
7323 16 tempitem.wpn=iwHover;
7324 16 break;
7325
7326 case iDivineFire:
7327 16 tempitem.power=8;
7328 16 tempitem.wpn=wDIVINEFIRE1A;
7329 16 tempitem.wpn2=wDIVINEFIRE1B;
7330 16 tempitem.wpn3=wDIVINEFIRES1A;
7331 16 tempitem.wpn4=wDIVINEFIRES1B;
7332 16 tempitem.misc1 = 32;
7333 16 tempitem.misc2 = 200;
7334 16 tempitem.cost_amount[0]=32;
7335 16 break;
7336
7337 case iDivineEscape:
7338 16 tempitem.cost_amount[0]=32;
7339 16 break;
7340
7341 case iHookshot:
7342 16 tempitem.power=0;
7343 16 tempitem.flags&=~ITEM_FLAG1;
7344 16 tempitem.wpn=wHSHEAD;
7345 16 tempitem.wpn2=wHSCHAIN_H;
7346 16 tempitem.wpn4=wHSHANDLE;
7347 16 tempitem.wpn3=wHSCHAIN_V;
7348 16 tempitem.misc1=50;
7349 16 tempitem.misc2=100;
7350 16 break;
7351
7352 case iLongshot:
7353 16 tempitem.power=0;
7354 16 tempitem.flags&=~ITEM_FLAG1;
7355 16 tempitem.wpn=wLSHEAD;
7356 16 tempitem.wpn2=wLSCHAIN_H;
7357 16 tempitem.wpn4=wLSHANDLE;
7358 16 tempitem.wpn3=wLSCHAIN_V;
7359 16 tempitem.misc1=99;
7360 16 tempitem.misc2=100;
7361 16 break;
7362
7363 case iHammer:
7364 16 tempitem.power=4;
7365 16 tempitem.wpn=wHAMMER;
7366 16 tempitem.wpn2=iwHammerSmack;
7367 16 break;
7368
7369 case iCByrna:
7370 16 tempitem.power=1;
7371 16 tempitem.wpn=wCBYRNA;
7372 16 tempitem.wpn2=wCBYRNASLASH;
7373 16 tempitem.wpn3=wCBYRNAORB;
7374 16 tempitem.misc1=4;
7375 16 tempitem.misc2=16;
7376 16 tempitem.misc3=1;
7377 16 tempitem.cost_amount[0]=1;
7378 16 break;
7379
7380 case iWhistle:
7381 16 tempitem.wpn=wWIND;
7382 16 tempitem.misc1=3;
7383 16 tempitem.flags|=ITEM_FLAG1;
7384 16 break;
7385
7386 case iBRing:
7387 16 tempitem.power=2;
7388 16 tempitem.misc1=spBLUE;
7389 16 break;
7390
7391 case iRRing:
7392 16 tempitem.power=4;
7393 16 tempitem.misc1=spRED;
7394 16 break;
7395
7396 case iGRing:
7397 16 tempitem.power=8;
7398 16 tempitem.misc1=spGOLD;
7399 16 break;
7400
7401 case iSpinScroll:
7402 16 tempitem.power = 2;
7403 16 tempitem.misc1 = 1;
7404 16 break;
7405
7406 case iL2SpinScroll:
7407 16 tempitem.family=itype_spinscroll2;
7408 16 tempitem.fam_type=1;
7409 16 tempitem.cost_amount[0]=8;
7410 16 tempitem.power=2;
7411 16 tempitem.misc1 = 20;
7412 16 break;
7413
7414 case iQuakeScroll:
7415 16 tempitem.misc1=0x10;
7416 16 tempitem.misc2=64;
7417 16 break;
7418
7419 case iL2QuakeScroll:
7420 16 tempitem.family=itype_quakescroll2;
7421 16 tempitem.fam_type=1;
7422 16 tempitem.power = 2;
7423 16 tempitem.misc1=0x20;
7424 16 tempitem.misc2=192;
7425 16 tempitem.cost_amount[0]=8;
7426 16 break;
7427
7428 case iChargeRing:
7429 16 tempitem.misc1=64;
7430 16 tempitem.misc2=128;
7431 16 break;
7432
7433 case iL2ChargeRing:
7434 16 tempitem.misc1=32;
7435 16 tempitem.misc2=64;
7436 16 break;
7437
7438 case iOldGlove:
7439 16 tempitem.flags |= ITEM_FLAG1;
7440
7441 //fallthrough
7442 case iBombBagL4:
7443 case iWalletL3:
7444 case iQuiverL4:
7445 case iBracelet:
7446 80 tempitem.power = 1;
7447 80 break;
7448
7449 case iL2Bracelet:
7450 16 tempitem.power = 2;
7451 16 break;
7452
7453 case iMKey:
7454 16 tempitem.power=0xFF;
7455 16 tempitem.flags |= ITEM_FLAG1;
7456 16 break;
7457 }
7458 4096 }
7459
7460
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 7)
7461 {
7462
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4032 times.
4096 switch(i)
7463 {
7464 case iStoneAgony:
7465 case iStompBoots:
7466 case iPerilRing:
7467 case iWhimsicalRing:
7468 {
7469 64 reset_itembuf(&tempitem, i);
7470 64 strcpy(item_string[i],old_item_string[i]);
7471 64 break;
7472 }
7473 }
7474 4096 }
7475
7476
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 8) // May 2007: Some corrections.
7477 {
7478
7/7
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 3968 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
4096 switch(i)
7479 {
7480 case iMShield:
7481 16 tempitem.misc1|=shFLAME;
7482 16 tempitem.misc2|=shFIREBALL|shMAGIC;
7483
7484
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_qr(qr_SWORDMIRROR))
7485 {
7486 tempitem.misc2 |= shSWORD;
7487 }
7488
7489 // fallthrough
7490 case iShield:
7491 32 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7492
7493 // fallthrough
7494 case iSShield:
7495 48 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7496
7497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7498 {
7499 tempitem.misc2 |= shROCK;
7500 }
7501
7502 48 break;
7503
7504 case iWhispRing:
7505 16 tempitem.power=1;
7506 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7507 16 tempitem.misc1 = 3;
7508 16 break;
7509
7510 case iL2WhispRing:
7511 16 tempitem.power=0;
7512 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7513 16 tempitem.misc1 = 3;
7514 16 break;
7515
7516 case iL2Ladder:
7517 case iBow:
7518 case iCByrna:
7519 48 tempitem.power = 1;
7520 48 break;
7521 }
7522 4096 }
7523
7524
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 29184 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33280 if(s_version < 9 && i==iClock)
7525 {
7526 16 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7527 16 }
7528
7529 //add the misc flag for bomb
7530
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 29184 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33280 if(s_version < 10 && tempitem.family == itype_bomb)
7531 {
7532 16 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7533 16 }
7534
7535
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 29184 times.
✓ Branch 2 taken 4064 times.
✓ Branch 3 taken 32 times.
33280 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7536 {
7537 32 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7538 32 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7539 32 }
7540
7541
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 12) // June 2007: More Misc. attributes.
7542 {
7543
5/5
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4016 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
4096 switch(i)
7544 {
7545 case iFBrang:
7546 16 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7547
7548 //fallthrough
7549 case iMBrang:
7550 32 tempitem.misc3 |= shSWORD|shMAGIC;
7551
7552 //fallthrough
7553 case iHookshot:
7554 case iLongshot:
7555 //fallthrough
7556 64 tempitem.misc3 |= shFIREBALL;
7557
7558 case iBrang:
7559 80 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7560 80 break;
7561 }
7562
7563
16/16
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 1740 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 64 times.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 1956 times.
4096 switch(tempitem.family)
7564 {
7565 case itype_hoverboots:
7566 16 tempitem.usesound = WAV_ZN1HOVER;
7567 16 break;
7568
7569 case itype_wand:
7570 16 tempitem.usesound = WAV_WAND;
7571 16 break;
7572
7573 case itype_book:
7574 16 tempitem.usesound = WAV_FIRE;
7575 16 break;
7576
7577 case itype_arrow:
7578 48 tempitem.usesound = WAV_ARROW;
7579 48 break;
7580
7581 case itype_hookshot:
7582 32 tempitem.usesound = WAV_HOOKSHOT;
7583 32 break;
7584
7585 case itype_brang:
7586 48 tempitem.usesound = WAV_BRANG;
7587 48 break;
7588
7589 case itype_shield:
7590 48 tempitem.usesound = WAV_CHINK;
7591 48 break;
7592
7593 case itype_sword:
7594 1740 tempitem.usesound = WAV_SWORD;
7595 1740 break;
7596
7597 case itype_whistle:
7598 16 tempitem.usesound = WAV_WHISTLE;
7599 16 break;
7600
7601 case itype_hammer:
7602 16 tempitem.usesound = WAV_HAMMER;
7603 16 break;
7604
7605 case itype_divinefire:
7606 16 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7607 16 break;
7608
7609 case itype_divineescape:
7610 16 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7611 16 break;
7612
7613 case itype_divineprotection:
7614 16 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7615 16 break;
7616
7617 case itype_bomb:
7618 case itype_sbomb:
7619 case itype_quakescroll:
7620 case itype_quakescroll2:
7621 64 tempitem.usesound = WAV_BOMB;
7622 64 break;
7623
7624 case itype_spinscroll:
7625 case itype_spinscroll2:
7626 32 tempitem.usesound = WAV_ZN1SPINATTACK;
7627 32 break;
7628 }
7629 4096 }
7630
7631
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 13) // July 2007
7632 {
7633
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7634 {
7635 16 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7636 16 tempitem.power = 1;
7637 16 tempitem.flags|=ITEM_FLAG1;
7638 16 }
7639
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_wand)
7640 16 tempitem.flags|=ITEM_FLAG1;
7641
2/2
✓ Branch 0 taken 4048 times.
✓ Branch 1 taken 16 times.
4064 else if(tempitem.family == itype_book)
7642 {
7643 16 tempitem.flags|=ITEM_FLAG1;
7644 16 tempitem.power = 2;
7645 16 }
7646 4096 }
7647
7648
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 14) // August 2007
7649 {
7650
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
4096 if(tempitem.family == itype_fairy)
7651 {
7652 32 tempitem.usesound = WAV_SCALE;
7653
7654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(tempitem.fam_type)
7655 32 tempitem.misc3=50;
7656 32 }
7657
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_potion)
7658 {
7659 32 tempitem.flags |= ITEM_GAINOLD;
7660 32 }
7661 4096 }
7662
7663
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 17) // November 2007
7664 {
7665
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
4096 if(tempitem.family == itype_candle && !tempitem.wpn3)
7666 {
7667 tempitem.wpn3 = wFIRE;
7668 }
7669
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 4048 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 16 times.
4096 else if(tempitem.family == itype_arrow && tempitem.power>4)
7670 {
7671 16 tempitem.flags|=ITEM_FLAG1;
7672 16 }
7673 4096 }
7674
7675
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 18) // New Year's Eve 2007
7676 {
7677
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7678 16 tempitem.misc2 = 8; // Use the Whistle warp ring
7679
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_bait)
7680 16 tempitem.misc1 = 768; // Frames until it goes
7681
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_triforcepiece)
7682 {
7683
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
32 if(tempitem.flags & ITEM_GAMEDATA)
7684 {
7685 16 tempitem.misc2 = 1; // Cutscene 1
7686 16 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7687 16 }
7688 32 }
7689 4096 }
7690
7691
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 19) // January 2008
7692 {
7693
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7694 {
7695 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7696 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7697 16 }
7698 4096 }
7699
7700
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 20) // October 2008
7701 {
7702
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7703 {
7704 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7705 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7706 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7707 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7708 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7709 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7710 16 }
7711 4096 }
7712
7713
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 21) // November 2008
7714 {
7715
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(tempitem.flags & 0x0100) // ITEM_SLASH
7716 {
7717 tempitem.flags &= ~0x0100;
7718
7719 if(tempitem.family == itype_sword ||
7720 tempitem.family == itype_wand ||
7721 tempitem.family == itype_candle ||
7722 tempitem.family == itype_cbyrna)
7723 {
7724 tempitem.flags |= ITEM_FLAG4;
7725 }
7726 }
7727 4096 }
7728
7729
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 22) // September 2009
7730 {
7731
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7732 {
7733 32 tempitem.misc3 = tempitem.power/2;
7734 32 }
7735 4096 }
7736
7737
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 23) // March 2011
7738 {
7739
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_divinefire)
7740 16 tempitem.wpn5 = wFIRE;
7741
2/2
✓ Branch 0 taken 4064 times.
✓ Branch 1 taken 16 times.
4080 else if(tempitem.family == itype_book)
7742 16 tempitem.wpn2 = wFIRE;
7743 4096 }
7744
7745 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7746 // whether it was or not, and a lot of existing quests depended on the
7747 // incorrect behavior.
7748
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 25) // January 2012
7749 {
7750
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 64 times.
4096 if(tempitem.family == itype_bombbag)
7751 64 tempitem.flags |= 16;
7752
7753
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divinefire)
7754 16 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7755 4096 }
7756
7757
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7758 {
7759
60/60
✓ Branch 0 taken 7811 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 274 times.
✓ Branch 3 taken 222 times.
✓ Branch 4 taken 138 times.
✓ Branch 5 taken 93 times.
✓ Branch 6 taken 184 times.
✓ Branch 7 taken 183 times.
✓ Branch 8 taken 107 times.
✓ Branch 9 taken 302 times.
✓ Branch 10 taken 276 times.
✓ Branch 11 taken 183 times.
✓ Branch 12 taken 283 times.
✓ Branch 13 taken 184 times.
✓ Branch 14 taken 92 times.
✓ Branch 15 taken 184 times.
✓ Branch 16 taken 107 times.
✓ Branch 17 taken 92 times.
✓ Branch 18 taken 279 times.
✓ Branch 19 taken 93 times.
✓ Branch 20 taken 94 times.
✓ Branch 21 taken 184 times.
✓ Branch 22 taken 92 times.
✓ Branch 23 taken 93 times.
✓ Branch 24 taken 92 times.
✓ Branch 25 taken 92 times.
✓ Branch 26 taken 92 times.
✓ Branch 27 taken 107 times.
✓ Branch 28 taken 92 times.
✓ Branch 29 taken 93 times.
✓ Branch 30 taken 92 times.
✓ Branch 31 taken 93 times.
✓ Branch 32 taken 184 times.
✓ Branch 33 taken 368 times.
✓ Branch 34 taken 94 times.
✓ Branch 35 taken 92 times.
✓ Branch 36 taken 168 times.
✓ Branch 37 taken 368 times.
✓ Branch 38 taken 92 times.
✓ Branch 39 taken 92 times.
✓ Branch 40 taken 92 times.
✓ Branch 41 taken 92 times.
✓ Branch 42 taken 92 times.
✓ Branch 43 taken 185 times.
✓ Branch 44 taken 184 times.
✓ Branch 45 taken 92 times.
✓ Branch 46 taken 277 times.
✓ Branch 47 taken 278 times.
✓ Branch 48 taken 372 times.
✓ Branch 49 taken 92 times.
✓ Branch 50 taken 92 times.
✓ Branch 51 taken 92 times.
✓ Branch 52 taken 92 times.
✓ Branch 53 taken 92 times.
✓ Branch 54 taken 93 times.
✓ Branch 55 taken 2541 times.
✓ Branch 56 taken 983 times.
✓ Branch 57 taken 277 times.
✓ Branch 58 taken 1135 times.
✓ Branch 59 taken 2617 times.
23808 switch(tempitem.family)
7760 {
7761 case itype_sword:
7762 {
7763 7811 tempitem.flags &= ~(ITEM_FLAG5);
7764 7811 tempitem.misc3 = 0;
7765 7811 tempitem.misc4 = 0;
7766 7811 tempitem.misc5 = 0;
7767 7811 tempitem.misc6 = 0;
7768 7811 tempitem.misc7 = 0;
7769 7811 tempitem.misc8 = 0;
7770 7811 tempitem.misc9 = 0;
7771 7811 tempitem.misc10 = 0;
7772 7811 tempitem.wpn4 = 0;
7773 7811 tempitem.wpn5 = 0;
7774 7811 tempitem.wpn6 = 0;
7775 7811 tempitem.wpn7 = 0;
7776 7811 tempitem.wpn8 = 0;
7777 7811 tempitem.wpn9 = 0;
7778 7811 tempitem.wpn10 = 0;
7779 7811 break;
7780 }
7781 case itype_brang:
7782 {
7783 277 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7784 277 tempitem.misc2 = 0;
7785 277 tempitem.misc5 = 0;
7786 277 tempitem.misc6 = 0;
7787 277 tempitem.misc7 = 0;
7788 277 tempitem.misc8 = 0;
7789 277 tempitem.misc9 = 0;
7790 277 tempitem.misc10 = 0;
7791 277 tempitem.wpn4 = 0;
7792 277 tempitem.wpn5 = 0;
7793 277 tempitem.wpn6 = 0;
7794 277 tempitem.wpn7 = 0;
7795 277 tempitem.wpn8 = 0;
7796 277 tempitem.wpn9 = 0;
7797 277 tempitem.wpn10 = 0;
7798 277 break;
7799 }
7800 case itype_arrow:
7801 {
7802 274 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7803 274 tempitem.misc2 = 0;
7804 274 tempitem.misc3 = 0;
7805 274 tempitem.misc4 = 0;
7806 274 tempitem.misc5 = 0;
7807 274 tempitem.misc6 = 0;
7808 274 tempitem.misc7 = 0;
7809 274 tempitem.misc8 = 0;
7810 274 tempitem.misc9 = 0;
7811 274 tempitem.misc10 = 0;
7812 274 tempitem.wpn4 = 0;
7813 274 tempitem.wpn5 = 0;
7814 274 tempitem.wpn6 = 0;
7815 274 tempitem.wpn7 = 0;
7816 274 tempitem.wpn8 = 0;
7817 274 tempitem.wpn9 = 0;
7818 274 tempitem.wpn10 = 0;
7819 274 break;
7820 }
7821 case itype_candle:
7822 {
7823 222 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7824 222 tempitem.misc1 = 0;
7825 222 tempitem.misc2 = 0;
7826 222 tempitem.misc3 = 0;
7827 222 tempitem.misc4 = 0;
7828 222 tempitem.misc5 = 0;
7829 222 tempitem.misc6 = 0;
7830 222 tempitem.misc7 = 0;
7831 222 tempitem.misc8 = 0;
7832 222 tempitem.misc9 = 0;
7833 222 tempitem.misc10 = 0;
7834 222 tempitem.wpn4 = 0;
7835 222 tempitem.wpn5 = 0;
7836 222 tempitem.wpn6 = 0;
7837 222 tempitem.wpn7 = 0;
7838 222 tempitem.wpn8 = 0;
7839 222 tempitem.wpn9 = 0;
7840 222 tempitem.wpn10 = 0;
7841 222 break;
7842 }
7843 case itype_whistle:
7844 {
7845 138 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7846 138 tempitem.misc3 = 0;
7847 138 tempitem.misc4 = 0;
7848 138 tempitem.misc5 = 0;
7849 138 tempitem.misc6 = 0;
7850 138 tempitem.misc7 = 0;
7851 138 tempitem.misc8 = 0;
7852 138 tempitem.misc9 = 0;
7853 138 tempitem.misc10 = 0;
7854 138 tempitem.wpn2 = 0;
7855 138 tempitem.wpn3 = 0;
7856 138 tempitem.wpn4 = 0;
7857 138 tempitem.wpn5 = 0;
7858 138 tempitem.wpn6 = 0;
7859 138 tempitem.wpn7 = 0;
7860 138 tempitem.wpn8 = 0;
7861 138 tempitem.wpn9 = 0;
7862 138 tempitem.wpn10 = 0;
7863 138 break;
7864 }
7865 case itype_bait:
7866 {
7867 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7868 93 tempitem.misc2 = 0;
7869 93 tempitem.misc3 = 0;
7870 93 tempitem.misc4 = 0;
7871 93 tempitem.misc5 = 0;
7872 93 tempitem.misc6 = 0;
7873 93 tempitem.misc7 = 0;
7874 93 tempitem.misc8 = 0;
7875 93 tempitem.misc9 = 0;
7876 93 tempitem.misc10 = 0;
7877 93 tempitem.wpn2 = 0;
7878 93 tempitem.wpn3 = 0;
7879 93 tempitem.wpn4 = 0;
7880 93 tempitem.wpn5 = 0;
7881 93 tempitem.wpn6 = 0;
7882 93 tempitem.wpn7 = 0;
7883 93 tempitem.wpn8 = 0;
7884 93 tempitem.wpn9 = 0;
7885 93 tempitem.wpn10 = 0;
7886 93 break;
7887 }
7888 case itype_letter:
7889 {
7890 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7891 184 tempitem.misc1 = 0;
7892 184 tempitem.misc2 = 0;
7893 184 tempitem.misc3 = 0;
7894 184 tempitem.misc4 = 0;
7895 184 tempitem.misc5 = 0;
7896 184 tempitem.misc6 = 0;
7897 184 tempitem.misc7 = 0;
7898 184 tempitem.misc8 = 0;
7899 184 tempitem.misc9 = 0;
7900 184 tempitem.misc10 = 0;
7901 184 tempitem.wpn = 0;
7902 184 tempitem.wpn2 = 0;
7903 184 tempitem.wpn3 = 0;
7904 184 tempitem.wpn4 = 0;
7905 184 tempitem.wpn5 = 0;
7906 184 tempitem.wpn6 = 0;
7907 184 tempitem.wpn7 = 0;
7908 184 tempitem.wpn8 = 0;
7909 184 tempitem.wpn9 = 0;
7910 184 tempitem.wpn10 = 0;
7911 184 break;
7912 }
7913 case itype_potion:
7914 {
7915 183 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7916 183 tempitem.misc3 = 0;
7917 183 tempitem.misc4 = 0;
7918 183 tempitem.misc5 = 0;
7919 183 tempitem.misc6 = 0;
7920 183 tempitem.misc7 = 0;
7921 183 tempitem.misc8 = 0;
7922 183 tempitem.misc9 = 0;
7923 183 tempitem.misc10 = 0;
7924 183 tempitem.wpn = 0;
7925 183 tempitem.wpn2 = 0;
7926 183 tempitem.wpn3 = 0;
7927 183 tempitem.wpn4 = 0;
7928 183 tempitem.wpn5 = 0;
7929 183 tempitem.wpn6 = 0;
7930 183 tempitem.wpn7 = 0;
7931 183 tempitem.wpn8 = 0;
7932 183 tempitem.wpn9 = 0;
7933 183 tempitem.wpn10 = 0;
7934 183 break;
7935 }
7936 case itype_wand:
7937 {
7938 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
7939 107 tempitem.misc1 = 0;
7940 107 tempitem.misc2 = 0;
7941 107 tempitem.misc3 = 0;
7942 107 tempitem.misc4 = 0;
7943 107 tempitem.misc5 = 0;
7944 107 tempitem.misc6 = 0;
7945 107 tempitem.misc7 = 0;
7946 107 tempitem.misc8 = 0;
7947 107 tempitem.misc9 = 0;
7948 107 tempitem.misc10 = 0;
7949 107 tempitem.wpn4 = 0;
7950 107 tempitem.wpn5 = 0;
7951 107 tempitem.wpn6 = 0;
7952 107 tempitem.wpn7 = 0;
7953 107 tempitem.wpn8 = 0;
7954 107 tempitem.wpn9 = 0;
7955 107 tempitem.wpn10 = 0;
7956 107 break;
7957 }
7958 case itype_ring:
7959 {
7960 302 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7961 302 tempitem.misc2 = 0;
7962 302 tempitem.misc3 = 0;
7963 302 tempitem.misc4 = 0;
7964 302 tempitem.misc5 = 0;
7965 302 tempitem.misc6 = 0;
7966 302 tempitem.misc7 = 0;
7967 302 tempitem.misc8 = 0;
7968 302 tempitem.misc9 = 0;
7969 302 tempitem.misc10 = 0;
7970 302 tempitem.wpn = 0;
7971 302 tempitem.wpn2 = 0;
7972 302 tempitem.wpn3 = 0;
7973 302 tempitem.wpn4 = 0;
7974 302 tempitem.wpn5 = 0;
7975 302 tempitem.wpn6 = 0;
7976 302 tempitem.wpn7 = 0;
7977 302 tempitem.wpn8 = 0;
7978 302 tempitem.wpn9 = 0;
7979 302 tempitem.wpn10 = 0;
7980 302 break;
7981 }
7982 case itype_wallet:
7983 {
7984 276 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7985 276 tempitem.misc3 = 0;
7986 276 tempitem.misc4 = 0;
7987 276 tempitem.misc5 = 0;
7988 276 tempitem.misc6 = 0;
7989 276 tempitem.misc7 = 0;
7990 276 tempitem.misc8 = 0;
7991 276 tempitem.misc9 = 0;
7992 276 tempitem.misc10 = 0;
7993 276 tempitem.wpn = 0;
7994 276 tempitem.wpn2 = 0;
7995 276 tempitem.wpn3 = 0;
7996 276 tempitem.wpn4 = 0;
7997 276 tempitem.wpn5 = 0;
7998 276 tempitem.wpn6 = 0;
7999 276 tempitem.wpn7 = 0;
8000 276 tempitem.wpn8 = 0;
8001 276 tempitem.wpn9 = 0;
8002 276 tempitem.wpn10 = 0;
8003 276 break;
8004 }
8005 case itype_amulet:
8006 {
8007 183 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8008 183 tempitem.misc1 = 0;
8009 183 tempitem.misc2 = 0;
8010 183 tempitem.misc3 = 0;
8011 183 tempitem.misc4 = 0;
8012 183 tempitem.misc5 = 0;
8013 183 tempitem.misc6 = 0;
8014 183 tempitem.misc7 = 0;
8015 183 tempitem.misc8 = 0;
8016 183 tempitem.misc9 = 0;
8017 183 tempitem.misc10 = 0;
8018 183 tempitem.wpn = 0;
8019 183 tempitem.wpn2 = 0;
8020 183 tempitem.wpn3 = 0;
8021 183 tempitem.wpn4 = 0;
8022 183 tempitem.wpn5 = 0;
8023 183 tempitem.wpn6 = 0;
8024 183 tempitem.wpn7 = 0;
8025 183 tempitem.wpn8 = 0;
8026 183 tempitem.wpn9 = 0;
8027 183 tempitem.wpn10 = 0;
8028 183 break;
8029 }
8030 case itype_shield:
8031 {
8032 283 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8033 283 tempitem.misc3 = 0;
8034 283 tempitem.misc4 = 0;
8035 283 tempitem.misc5 = 0;
8036 283 tempitem.misc6 = 0;
8037 283 tempitem.misc7 = 0;
8038 283 tempitem.misc8 = 0;
8039 283 tempitem.misc9 = 0;
8040 283 tempitem.misc10 = 0;
8041 283 tempitem.wpn = 0;
8042 283 tempitem.wpn2 = 0;
8043 283 tempitem.wpn3 = 0;
8044 283 tempitem.wpn4 = 0;
8045 283 tempitem.wpn5 = 0;
8046 283 tempitem.wpn6 = 0;
8047 283 tempitem.wpn7 = 0;
8048 283 tempitem.wpn8 = 0;
8049 283 tempitem.wpn9 = 0;
8050 283 tempitem.wpn10 = 0;
8051 283 break;
8052 }
8053 case itype_bow:
8054 {
8055 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8056 184 tempitem.misc1 = 0;
8057 184 tempitem.misc2 = 0;
8058 184 tempitem.misc3 = 0;
8059 184 tempitem.misc4 = 0;
8060 184 tempitem.misc5 = 0;
8061 184 tempitem.misc6 = 0;
8062 184 tempitem.misc7 = 0;
8063 184 tempitem.misc8 = 0;
8064 184 tempitem.misc9 = 0;
8065 184 tempitem.misc10 = 0;
8066 184 tempitem.wpn = 0;
8067 184 tempitem.wpn2 = 0;
8068 184 tempitem.wpn3 = 0;
8069 184 tempitem.wpn4 = 0;
8070 184 tempitem.wpn5 = 0;
8071 184 tempitem.wpn6 = 0;
8072 184 tempitem.wpn7 = 0;
8073 184 tempitem.wpn8 = 0;
8074 184 tempitem.wpn9 = 0;
8075 184 tempitem.wpn10 = 0;
8076 184 break;
8077 }
8078 case itype_raft:
8079 {
8080 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8081 92 tempitem.misc1 = 0;
8082 92 tempitem.misc2 = 0;
8083 92 tempitem.misc3 = 0;
8084 92 tempitem.misc4 = 0;
8085 92 tempitem.misc5 = 0;
8086 92 tempitem.misc6 = 0;
8087 92 tempitem.misc7 = 0;
8088 92 tempitem.misc8 = 0;
8089 92 tempitem.misc9 = 0;
8090 92 tempitem.misc10 = 0;
8091 92 tempitem.wpn = 0;
8092 92 tempitem.wpn2 = 0;
8093 92 tempitem.wpn3 = 0;
8094 92 tempitem.wpn4 = 0;
8095 92 tempitem.wpn5 = 0;
8096 92 tempitem.wpn6 = 0;
8097 92 tempitem.wpn7 = 0;
8098 92 tempitem.wpn8 = 0;
8099 92 tempitem.wpn9 = 0;
8100 92 tempitem.wpn10 = 0;
8101 92 break;
8102 }
8103 case itype_ladder:
8104 {
8105 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8106 184 tempitem.misc1 = 0;
8107 184 tempitem.misc2 = 0;
8108 184 tempitem.misc3 = 0;
8109 184 tempitem.misc4 = 0;
8110 184 tempitem.misc5 = 0;
8111 184 tempitem.misc6 = 0;
8112 184 tempitem.misc7 = 0;
8113 184 tempitem.misc8 = 0;
8114 184 tempitem.misc9 = 0;
8115 184 tempitem.misc10 = 0;
8116 184 tempitem.wpn = 0;
8117 184 tempitem.wpn2 = 0;
8118 184 tempitem.wpn3 = 0;
8119 184 tempitem.wpn4 = 0;
8120 184 tempitem.wpn5 = 0;
8121 184 tempitem.wpn6 = 0;
8122 184 tempitem.wpn7 = 0;
8123 184 tempitem.wpn8 = 0;
8124 184 tempitem.wpn9 = 0;
8125 184 tempitem.wpn10 = 0;
8126 184 break;
8127 }
8128 case itype_book:
8129 {
8130 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8131 107 tempitem.misc1 = 0;
8132 107 tempitem.misc2 = 0;
8133 107 tempitem.misc3 = 0;
8134 107 tempitem.misc4 = 0;
8135 107 tempitem.misc5 = 0;
8136 107 tempitem.misc6 = 0;
8137 107 tempitem.misc7 = 0;
8138 107 tempitem.misc8 = 0;
8139 107 tempitem.misc9 = 0;
8140 107 tempitem.misc10 = 0;
8141 107 tempitem.wpn3 = 0;
8142 107 tempitem.wpn4 = 0;
8143 107 tempitem.wpn5 = 0;
8144 107 tempitem.wpn6 = 0;
8145 107 tempitem.wpn7 = 0;
8146 107 tempitem.wpn8 = 0;
8147 107 tempitem.wpn9 = 0;
8148 107 tempitem.wpn10 = 0;
8149 107 break;
8150 }
8151 case itype_magickey:
8152 {
8153 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8154 92 tempitem.misc1 = 0;
8155 92 tempitem.misc2 = 0;
8156 92 tempitem.misc3 = 0;
8157 92 tempitem.misc4 = 0;
8158 92 tempitem.misc5 = 0;
8159 92 tempitem.misc6 = 0;
8160 92 tempitem.misc7 = 0;
8161 92 tempitem.misc8 = 0;
8162 92 tempitem.misc9 = 0;
8163 92 tempitem.misc10 = 0;
8164 92 tempitem.wpn = 0;
8165 92 tempitem.wpn2 = 0;
8166 92 tempitem.wpn3 = 0;
8167 92 tempitem.wpn4 = 0;
8168 92 tempitem.wpn5 = 0;
8169 92 tempitem.wpn6 = 0;
8170 92 tempitem.wpn7 = 0;
8171 92 tempitem.wpn8 = 0;
8172 92 tempitem.wpn9 = 0;
8173 92 tempitem.wpn10 = 0;
8174 92 break;
8175 }
8176 case itype_bracelet:
8177 {
8178 279 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8179 279 tempitem.misc1 = 0;
8180 279 tempitem.misc2 = 0;
8181 279 tempitem.misc3 = 0;
8182 279 tempitem.misc4 = 0;
8183 279 tempitem.misc5 = 0;
8184 279 tempitem.misc6 = 0;
8185 279 tempitem.misc7 = 0;
8186 279 tempitem.misc8 = 0;
8187 279 tempitem.misc9 = 0;
8188 279 tempitem.misc10 = 0;
8189 279 tempitem.wpn = 0;
8190 279 tempitem.wpn2 = 0;
8191 279 tempitem.wpn3 = 0;
8192 279 tempitem.wpn4 = 0;
8193 279 tempitem.wpn5 = 0;
8194 279 tempitem.wpn6 = 0;
8195 279 tempitem.wpn7 = 0;
8196 279 tempitem.wpn8 = 0;
8197 279 tempitem.wpn9 = 0;
8198 279 tempitem.wpn10 = 0;
8199 279 break;
8200 }
8201 case itype_flippers:
8202 {
8203 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8204 93 tempitem.misc1 = 0;
8205 93 tempitem.misc2 = 0;
8206 93 tempitem.misc3 = 0;
8207 93 tempitem.misc4 = 0;
8208 93 tempitem.misc5 = 0;
8209 93 tempitem.misc6 = 0;
8210 93 tempitem.misc7 = 0;
8211 93 tempitem.misc8 = 0;
8212 93 tempitem.misc9 = 0;
8213 93 tempitem.misc10 = 0;
8214 93 tempitem.wpn = 0;
8215 93 tempitem.wpn2 = 0;
8216 93 tempitem.wpn3 = 0;
8217 93 tempitem.wpn4 = 0;
8218 93 tempitem.wpn5 = 0;
8219 93 tempitem.wpn6 = 0;
8220 93 tempitem.wpn7 = 0;
8221 93 tempitem.wpn8 = 0;
8222 93 tempitem.wpn9 = 0;
8223 93 tempitem.wpn10 = 0;
8224 93 break;
8225 }
8226 case itype_boots:
8227 {
8228 94 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8229 94 tempitem.misc1 = 0;
8230 94 tempitem.misc2 = 0;
8231 94 tempitem.misc3 = 0;
8232 94 tempitem.misc4 = 0;
8233 94 tempitem.misc5 = 0;
8234 94 tempitem.misc6 = 0;
8235 94 tempitem.misc7 = 0;
8236 94 tempitem.misc8 = 0;
8237 94 tempitem.misc9 = 0;
8238 94 tempitem.misc10 = 0;
8239 94 tempitem.wpn = 0;
8240 94 tempitem.wpn2 = 0;
8241 94 tempitem.wpn3 = 0;
8242 94 tempitem.wpn4 = 0;
8243 94 tempitem.wpn5 = 0;
8244 94 tempitem.wpn6 = 0;
8245 94 tempitem.wpn7 = 0;
8246 94 tempitem.wpn8 = 0;
8247 94 tempitem.wpn9 = 0;
8248 94 tempitem.wpn10 = 0;
8249 94 break;
8250 }
8251 case itype_hookshot:
8252 {
8253 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8254 184 tempitem.misc5 = 0;
8255 184 tempitem.misc6 = 0;
8256 184 tempitem.misc7 = 0;
8257 184 tempitem.misc8 = 0;
8258 184 tempitem.misc9 = 0;
8259 184 tempitem.misc10 = 0;
8260 184 tempitem.wpn5 = 0;
8261 184 tempitem.wpn6 = 0;
8262 184 tempitem.wpn7 = 0;
8263 184 tempitem.wpn8 = 0;
8264 184 tempitem.wpn9 = 0;
8265 184 tempitem.wpn10 = 0;
8266 184 break;
8267 }
8268 case itype_lens:
8269 {
8270 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8271 92 tempitem.misc2 = 0;
8272 92 tempitem.misc3 = 0;
8273 92 tempitem.misc4 = 0;
8274 92 tempitem.misc5 = 0;
8275 92 tempitem.misc6 = 0;
8276 92 tempitem.misc7 = 0;
8277 92 tempitem.misc8 = 0;
8278 92 tempitem.misc9 = 0;
8279 92 tempitem.misc10 = 0;
8280 92 tempitem.wpn = 0;
8281 92 tempitem.wpn2 = 0;
8282 92 tempitem.wpn3 = 0;
8283 92 tempitem.wpn4 = 0;
8284 92 tempitem.wpn5 = 0;
8285 92 tempitem.wpn6 = 0;
8286 92 tempitem.wpn7 = 0;
8287 92 tempitem.wpn8 = 0;
8288 92 tempitem.wpn9 = 0;
8289 92 tempitem.wpn10 = 0;
8290 92 break;
8291 }
8292 case itype_hammer:
8293 {
8294 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8295 93 tempitem.misc1 = 0;
8296 93 tempitem.misc2 = 0;
8297 93 tempitem.misc3 = 0;
8298 93 tempitem.misc4 = 0;
8299 93 tempitem.misc5 = 0;
8300 93 tempitem.misc6 = 0;
8301 93 tempitem.misc7 = 0;
8302 93 tempitem.misc8 = 0;
8303 93 tempitem.misc9 = 0;
8304 93 tempitem.misc10 = 0;
8305 93 tempitem.wpn3 = 0;
8306 93 tempitem.wpn4 = 0;
8307 93 tempitem.wpn5 = 0;
8308 93 tempitem.wpn6 = 0;
8309 93 tempitem.wpn7 = 0;
8310 93 tempitem.wpn8 = 0;
8311 93 tempitem.wpn9 = 0;
8312 93 tempitem.wpn10 = 0;
8313 93 break;
8314 }
8315 case itype_divinefire:
8316 {
8317 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8318 92 tempitem.misc3 = 0;
8319 92 tempitem.misc4 = 0;
8320 92 tempitem.misc5 = 0;
8321 92 tempitem.misc6 = 0;
8322 92 tempitem.misc7 = 0;
8323 92 tempitem.misc8 = 0;
8324 92 tempitem.misc9 = 0;
8325 92 tempitem.misc10 = 0;
8326 92 tempitem.wpn6 = 0;
8327 92 tempitem.wpn7 = 0;
8328 92 tempitem.wpn8 = 0;
8329 92 tempitem.wpn9 = 0;
8330 92 tempitem.wpn10 = 0;
8331 92 break;
8332 }
8333 case itype_divineescape:
8334 {
8335 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8336 92 tempitem.misc2 = 0;
8337 92 tempitem.misc3 = 0;
8338 92 tempitem.misc4 = 0;
8339 92 tempitem.misc5 = 0;
8340 92 tempitem.misc6 = 0;
8341 92 tempitem.misc7 = 0;
8342 92 tempitem.misc8 = 0;
8343 92 tempitem.misc9 = 0;
8344 92 tempitem.misc10 = 0;
8345 92 tempitem.wpn = 0;
8346 92 tempitem.wpn2 = 0;
8347 92 tempitem.wpn3 = 0;
8348 92 tempitem.wpn4 = 0;
8349 92 tempitem.wpn5 = 0;
8350 92 tempitem.wpn6 = 0;
8351 92 tempitem.wpn7 = 0;
8352 92 tempitem.wpn8 = 0;
8353 92 tempitem.wpn9 = 0;
8354 92 tempitem.wpn10 = 0;
8355 92 break;
8356 }
8357 case itype_divineprotection:
8358 {
8359 92 tempitem.flags &= ~ (ITEM_FLAG5);
8360 92 tempitem.misc2 = 0;
8361 92 tempitem.misc3 = 0;
8362 92 tempitem.misc4 = 0;
8363 92 tempitem.misc5 = 0;
8364 92 tempitem.misc6 = 0;
8365 92 tempitem.misc7 = 0;
8366 92 tempitem.misc8 = 0;
8367 92 tempitem.misc9 = 0;
8368 92 tempitem.misc10 = 0;
8369 92 break;
8370 }
8371 case itype_bomb:
8372 {
8373 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8374 107 tempitem.misc4 = 0;
8375 107 tempitem.misc5 = 0;
8376 107 tempitem.misc6 = 0;
8377 107 tempitem.misc7 = 0;
8378 107 tempitem.misc8 = 0;
8379 107 tempitem.misc9 = 0;
8380 107 tempitem.misc10 = 0;
8381 107 tempitem.wpn3 = 0;
8382 107 tempitem.wpn4 = 0;
8383 107 tempitem.wpn5 = 0;
8384 107 tempitem.wpn6 = 0;
8385 107 tempitem.wpn7 = 0;
8386 107 tempitem.wpn8 = 0;
8387 107 tempitem.wpn9 = 0;
8388 107 tempitem.wpn10 = 0;
8389 107 break;
8390 }
8391 case itype_sbomb:
8392 {
8393 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8394 92 tempitem.misc4 = 0;
8395 92 tempitem.misc5 = 0;
8396 92 tempitem.misc6 = 0;
8397 92 tempitem.misc7 = 0;
8398 92 tempitem.misc8 = 0;
8399 92 tempitem.misc9 = 0;
8400 92 tempitem.misc10 = 0;
8401 92 tempitem.wpn3 = 0;
8402 92 tempitem.wpn4 = 0;
8403 92 tempitem.wpn5 = 0;
8404 92 tempitem.wpn6 = 0;
8405 92 tempitem.wpn7 = 0;
8406 92 tempitem.wpn8 = 0;
8407 92 tempitem.wpn9 = 0;
8408 92 tempitem.wpn10 = 0;
8409 92 break;
8410 }
8411 case itype_clock:
8412 {
8413 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8414 93 tempitem.misc2 = 0;
8415 93 tempitem.misc3 = 0;
8416 93 tempitem.misc4 = 0;
8417 93 tempitem.misc5 = 0;
8418 93 tempitem.misc6 = 0;
8419 93 tempitem.misc7 = 0;
8420 93 tempitem.misc8 = 0;
8421 93 tempitem.misc9 = 0;
8422 93 tempitem.misc10 = 0;
8423 93 tempitem.wpn = 0;
8424 93 tempitem.wpn2 = 0;
8425 93 tempitem.wpn3 = 0;
8426 93 tempitem.wpn4 = 0;
8427 93 tempitem.wpn5 = 0;
8428 93 tempitem.wpn6 = 0;
8429 93 tempitem.wpn7 = 0;
8430 93 tempitem.wpn8 = 0;
8431 93 tempitem.wpn9 = 0;
8432 93 tempitem.wpn10 = 0;
8433 93 break;
8434 }
8435 case itype_key:
8436 {
8437 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8438 92 tempitem.misc1 = 0;
8439 92 tempitem.misc2 = 0;
8440 92 tempitem.misc3 = 0;
8441 92 tempitem.misc4 = 0;
8442 92 tempitem.misc5 = 0;
8443 92 tempitem.misc6 = 0;
8444 92 tempitem.misc7 = 0;
8445 92 tempitem.misc8 = 0;
8446 92 tempitem.misc9 = 0;
8447 92 tempitem.misc10 = 0;
8448 92 tempitem.wpn = 0;
8449 92 tempitem.wpn2 = 0;
8450 92 tempitem.wpn3 = 0;
8451 92 tempitem.wpn4 = 0;
8452 92 tempitem.wpn5 = 0;
8453 92 tempitem.wpn6 = 0;
8454 92 tempitem.wpn7 = 0;
8455 92 tempitem.wpn8 = 0;
8456 92 tempitem.wpn9 = 0;
8457 92 tempitem.wpn10 = 0;
8458 92 break;
8459 }
8460 case itype_magiccontainer:
8461 {
8462 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8463 93 tempitem.misc1 = 0;
8464 93 tempitem.misc2 = 0;
8465 93 tempitem.misc3 = 0;
8466 93 tempitem.misc4 = 0;
8467 93 tempitem.misc5 = 0;
8468 93 tempitem.misc6 = 0;
8469 93 tempitem.misc7 = 0;
8470 93 tempitem.misc8 = 0;
8471 93 tempitem.misc9 = 0;
8472 93 tempitem.misc10 = 0;
8473 93 tempitem.wpn = 0;
8474 93 tempitem.wpn2 = 0;
8475 93 tempitem.wpn3 = 0;
8476 93 tempitem.wpn4 = 0;
8477 93 tempitem.wpn5 = 0;
8478 93 tempitem.wpn6 = 0;
8479 93 tempitem.wpn7 = 0;
8480 93 tempitem.wpn8 = 0;
8481 93 tempitem.wpn9 = 0;
8482 93 tempitem.wpn10 = 0;
8483 93 break;
8484 }
8485 case itype_triforcepiece:
8486 {
8487 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8488 184 tempitem.misc3 = 0;
8489 184 tempitem.misc4 = 0;
8490 184 tempitem.misc5 = 0;
8491 184 tempitem.misc6 = 0;
8492 184 tempitem.misc7 = 0;
8493 184 tempitem.misc8 = 0;
8494 184 tempitem.misc9 = 0;
8495 184 tempitem.misc10 = 0;
8496 184 tempitem.wpn = 0;
8497 184 tempitem.wpn2 = 0;
8498 184 tempitem.wpn3 = 0;
8499 184 tempitem.wpn4 = 0;
8500 184 tempitem.wpn5 = 0;
8501 184 tempitem.wpn6 = 0;
8502 184 tempitem.wpn7 = 0;
8503 184 tempitem.wpn8 = 0;
8504 184 tempitem.wpn9 = 0;
8505 184 tempitem.wpn10 = 0;
8506 184 break;
8507 }
8508 case itype_map: case itype_compass: case itype_bosskey:
8509 {
8510 277 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8511 277 tempitem.misc1 = 0;
8512 277 tempitem.misc2 = 0;
8513 277 tempitem.misc3 = 0;
8514 277 tempitem.misc4 = 0;
8515 277 tempitem.misc5 = 0;
8516 277 tempitem.misc6 = 0;
8517 277 tempitem.misc7 = 0;
8518 277 tempitem.misc8 = 0;
8519 277 tempitem.misc9 = 0;
8520 277 tempitem.misc10 = 0;
8521 277 tempitem.wpn = 0;
8522 277 tempitem.wpn2 = 0;
8523 277 tempitem.wpn3 = 0;
8524 277 tempitem.wpn4 = 0;
8525 277 tempitem.wpn5 = 0;
8526 277 tempitem.wpn6 = 0;
8527 277 tempitem.wpn7 = 0;
8528 277 tempitem.wpn8 = 0;
8529 277 tempitem.wpn9 = 0;
8530 277 tempitem.wpn10 = 0;
8531 277 break;
8532 }
8533 case itype_quiver:
8534 {
8535 368 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8536 368 tempitem.misc3 = 0;
8537 368 tempitem.misc4 = 0;
8538 368 tempitem.misc5 = 0;
8539 368 tempitem.misc6 = 0;
8540 368 tempitem.misc7 = 0;
8541 368 tempitem.misc8 = 0;
8542 368 tempitem.misc9 = 0;
8543 368 tempitem.misc10 = 0;
8544 368 tempitem.wpn = 0;
8545 368 tempitem.wpn2 = 0;
8546 368 tempitem.wpn3 = 0;
8547 368 tempitem.wpn4 = 0;
8548 368 tempitem.wpn5 = 0;
8549 368 tempitem.wpn6 = 0;
8550 368 tempitem.wpn7 = 0;
8551 368 tempitem.wpn8 = 0;
8552 368 tempitem.wpn9 = 0;
8553 368 tempitem.wpn10 = 0;
8554 368 break;
8555 }
8556 case itype_lkey:
8557 {
8558 94 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8559 94 tempitem.misc1 = 0;
8560 94 tempitem.misc2 = 0;
8561 94 tempitem.misc3 = 0;
8562 94 tempitem.misc4 = 0;
8563 94 tempitem.misc5 = 0;
8564 94 tempitem.misc6 = 0;
8565 94 tempitem.misc7 = 0;
8566 94 tempitem.misc8 = 0;
8567 94 tempitem.misc9 = 0;
8568 94 tempitem.misc10 = 0;
8569 94 tempitem.wpn = 0;
8570 94 tempitem.wpn2 = 0;
8571 94 tempitem.wpn3 = 0;
8572 94 tempitem.wpn4 = 0;
8573 94 tempitem.wpn5 = 0;
8574 94 tempitem.wpn6 = 0;
8575 94 tempitem.wpn7 = 0;
8576 94 tempitem.wpn8 = 0;
8577 94 tempitem.wpn9 = 0;
8578 94 tempitem.wpn10 = 0;
8579 94 break;
8580 }
8581 case itype_cbyrna:
8582 {
8583 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8584 92 tempitem.misc4 = 0;
8585 92 tempitem.misc5 = 0;
8586 92 tempitem.misc6 = 0;
8587 92 tempitem.misc7 = 0;
8588 92 tempitem.misc8 = 0;
8589 92 tempitem.misc9 = 0;
8590 92 tempitem.misc10 = 0;
8591 92 tempitem.wpn6 = 0;
8592 92 tempitem.wpn7 = 0;
8593 92 tempitem.wpn8 = 0;
8594 92 tempitem.wpn9 = 0;
8595 92 tempitem.wpn10 = 0;
8596 92 break;
8597 }
8598 case itype_rupee: case itype_arrowammo:
8599 {
8600 1135 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8601 1135 tempitem.misc1 = 0;
8602 1135 tempitem.misc2 = 0;
8603 1135 tempitem.misc3 = 0;
8604 1135 tempitem.misc4 = 0;
8605 1135 tempitem.misc5 = 0;
8606 1135 tempitem.misc6 = 0;
8607 1135 tempitem.misc7 = 0;
8608 1135 tempitem.misc8 = 0;
8609 1135 tempitem.misc9 = 0;
8610 1135 tempitem.misc10 = 0;
8611 1135 tempitem.wpn = 0;
8612 1135 tempitem.wpn2 = 0;
8613 1135 tempitem.wpn3 = 0;
8614 1135 tempitem.wpn4 = 0;
8615 1135 tempitem.wpn5 = 0;
8616 1135 tempitem.wpn6 = 0;
8617 1135 tempitem.wpn7 = 0;
8618 1135 tempitem.wpn8 = 0;
8619 1135 tempitem.wpn9 = 0;
8620 1135 tempitem.wpn10 = 0;
8621 1135 break;
8622 }
8623 case itype_fairy:
8624 {
8625 168 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8626 168 tempitem.misc4 = 0;
8627 168 tempitem.misc5 = 0;
8628 168 tempitem.misc6 = 0;
8629 168 tempitem.misc7 = 0;
8630 168 tempitem.misc8 = 0;
8631 168 tempitem.misc9 = 0;
8632 168 tempitem.misc10 = 0;
8633 168 tempitem.wpn = 0;
8634 168 tempitem.wpn2 = 0;
8635 168 tempitem.wpn3 = 0;
8636 168 tempitem.wpn4 = 0;
8637 168 tempitem.wpn5 = 0;
8638 168 tempitem.wpn6 = 0;
8639 168 tempitem.wpn7 = 0;
8640 168 tempitem.wpn8 = 0;
8641 168 tempitem.wpn9 = 0;
8642 168 tempitem.wpn10 = 0;
8643 168 break;
8644 }
8645 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8646 {
8647 983 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8648 983 tempitem.misc1 = 0;
8649 983 tempitem.misc2 = 0;
8650 983 tempitem.misc3 = 0;
8651 983 tempitem.misc4 = 0;
8652 983 tempitem.misc5 = 0;
8653 983 tempitem.misc6 = 0;
8654 983 tempitem.misc7 = 0;
8655 983 tempitem.misc8 = 0;
8656 983 tempitem.misc9 = 0;
8657 983 tempitem.misc10 = 0;
8658 983 tempitem.wpn = 0;
8659 983 tempitem.wpn2 = 0;
8660 983 tempitem.wpn3 = 0;
8661 983 tempitem.wpn4 = 0;
8662 983 tempitem.wpn5 = 0;
8663 983 tempitem.wpn6 = 0;
8664 983 tempitem.wpn7 = 0;
8665 983 tempitem.wpn8 = 0;
8666 983 tempitem.wpn9 = 0;
8667 983 tempitem.wpn10 = 0;
8668 983 break;
8669 }
8670 case itype_bombbag:
8671 {
8672 368 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8673 368 tempitem.misc3 = 0;
8674 368 tempitem.misc4 = 0;
8675 368 tempitem.misc5 = 0;
8676 368 tempitem.misc6 = 0;
8677 368 tempitem.misc7 = 0;
8678 368 tempitem.misc8 = 0;
8679 368 tempitem.misc9 = 0;
8680 368 tempitem.misc10 = 0;
8681 368 tempitem.wpn = 0;
8682 368 tempitem.wpn2 = 0;
8683 368 tempitem.wpn3 = 0;
8684 368 tempitem.wpn4 = 0;
8685 368 tempitem.wpn5 = 0;
8686 368 tempitem.wpn6 = 0;
8687 368 tempitem.wpn7 = 0;
8688 368 tempitem.wpn8 = 0;
8689 368 tempitem.wpn9 = 0;
8690 368 tempitem.wpn10 = 0;
8691 368 break;
8692 }
8693 case itype_rocs:
8694 {
8695 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8696 92 tempitem.misc1 = 0;
8697 92 tempitem.misc2 = 0;
8698 92 tempitem.misc3 = 0;
8699 92 tempitem.misc4 = 0;
8700 92 tempitem.misc5 = 0;
8701 92 tempitem.misc6 = 0;
8702 92 tempitem.misc7 = 0;
8703 92 tempitem.misc8 = 0;
8704 92 tempitem.misc9 = 0;
8705 92 tempitem.misc10 = 0;
8706 92 tempitem.wpn = 0;
8707 92 tempitem.wpn2 = 0;
8708 92 tempitem.wpn3 = 0;
8709 92 tempitem.wpn4 = 0;
8710 92 tempitem.wpn5 = 0;
8711 92 tempitem.wpn6 = 0;
8712 92 tempitem.wpn7 = 0;
8713 92 tempitem.wpn8 = 0;
8714 92 tempitem.wpn9 = 0;
8715 92 tempitem.wpn10 = 0;
8716 92 break;
8717 }
8718 case itype_hoverboots:
8719 {
8720 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8721 92 tempitem.misc2 = 0;
8722 92 tempitem.misc3 = 0;
8723 92 tempitem.misc4 = 0;
8724 92 tempitem.misc5 = 0;
8725 92 tempitem.misc6 = 0;
8726 92 tempitem.misc7 = 0;
8727 92 tempitem.misc8 = 0;
8728 92 tempitem.misc9 = 0;
8729 92 tempitem.misc10 = 0;
8730 92 tempitem.wpn2 = 0;
8731 92 tempitem.wpn3 = 0;
8732 92 tempitem.wpn4 = 0;
8733 92 tempitem.wpn5 = 0;
8734 92 tempitem.wpn6 = 0;
8735 92 tempitem.wpn7 = 0;
8736 92 tempitem.wpn8 = 0;
8737 92 tempitem.wpn9 = 0;
8738 92 tempitem.wpn10 = 0;
8739 92 break;
8740 }
8741 case itype_spinscroll:
8742 {
8743 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8744 92 tempitem.misc2 = 0;
8745 92 tempitem.misc3 = 0;
8746 92 tempitem.misc4 = 0;
8747 92 tempitem.misc5 = 0;
8748 92 tempitem.misc6 = 0;
8749 92 tempitem.misc7 = 0;
8750 92 tempitem.misc8 = 0;
8751 92 tempitem.misc9 = 0;
8752 92 tempitem.misc10 = 0;
8753 92 tempitem.wpn = 0;
8754 92 tempitem.wpn2 = 0;
8755 92 tempitem.wpn3 = 0;
8756 92 tempitem.wpn4 = 0;
8757 92 tempitem.wpn5 = 0;
8758 92 tempitem.wpn6 = 0;
8759 92 tempitem.wpn7 = 0;
8760 92 tempitem.wpn8 = 0;
8761 92 tempitem.wpn9 = 0;
8762 92 tempitem.wpn10 = 0;
8763 92 break;
8764 }
8765 case itype_crossscroll:
8766 {
8767 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8768 92 tempitem.misc1 = 0;
8769 92 tempitem.misc2 = 0;
8770 92 tempitem.misc3 = 0;
8771 92 tempitem.misc4 = 0;
8772 92 tempitem.misc5 = 0;
8773 92 tempitem.misc6 = 0;
8774 92 tempitem.misc7 = 0;
8775 92 tempitem.misc8 = 0;
8776 92 tempitem.misc9 = 0;
8777 92 tempitem.misc10 = 0;
8778 92 tempitem.wpn = 0;
8779 92 tempitem.wpn2 = 0;
8780 92 tempitem.wpn3 = 0;
8781 92 tempitem.wpn4 = 0;
8782 92 tempitem.wpn5 = 0;
8783 92 tempitem.wpn6 = 0;
8784 92 tempitem.wpn7 = 0;
8785 92 tempitem.wpn8 = 0;
8786 92 tempitem.wpn9 = 0;
8787 92 tempitem.wpn10 = 0;
8788 92 break;
8789 }
8790 case itype_quakescroll:
8791 {
8792 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8793 92 tempitem.misc3 = 0;
8794 92 tempitem.misc4 = 0;
8795 92 tempitem.misc5 = 0;
8796 92 tempitem.misc6 = 0;
8797 92 tempitem.misc7 = 0;
8798 92 tempitem.misc8 = 0;
8799 92 tempitem.misc9 = 0;
8800 92 tempitem.misc10 = 0;
8801 92 tempitem.wpn = 0;
8802 92 tempitem.wpn2 = 0;
8803 92 tempitem.wpn3 = 0;
8804 92 tempitem.wpn4 = 0;
8805 92 tempitem.wpn5 = 0;
8806 92 tempitem.wpn6 = 0;
8807 92 tempitem.wpn7 = 0;
8808 92 tempitem.wpn8 = 0;
8809 92 tempitem.wpn9 = 0;
8810 92 tempitem.wpn10 = 0;
8811 92 break;
8812 }
8813 case itype_whispring:
8814 {
8815 185 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8816 185 tempitem.misc2 = 0;
8817 185 tempitem.misc3 = 0;
8818 185 tempitem.misc4 = 0;
8819 185 tempitem.misc5 = 0;
8820 185 tempitem.misc6 = 0;
8821 185 tempitem.misc7 = 0;
8822 185 tempitem.misc8 = 0;
8823 185 tempitem.misc9 = 0;
8824 185 tempitem.misc10 = 0;
8825 185 tempitem.wpn = 0;
8826 185 tempitem.wpn2 = 0;
8827 185 tempitem.wpn3 = 0;
8828 185 tempitem.wpn4 = 0;
8829 185 tempitem.wpn5 = 0;
8830 185 tempitem.wpn6 = 0;
8831 185 tempitem.wpn7 = 0;
8832 185 tempitem.wpn8 = 0;
8833 185 tempitem.wpn9 = 0;
8834 185 tempitem.wpn10 = 0;
8835 185 break;
8836 }
8837 case itype_chargering:
8838 {
8839 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8840 184 tempitem.misc3 = 0;
8841 184 tempitem.misc4 = 0;
8842 184 tempitem.misc5 = 0;
8843 184 tempitem.misc6 = 0;
8844 184 tempitem.misc7 = 0;
8845 184 tempitem.misc8 = 0;
8846 184 tempitem.misc9 = 0;
8847 184 tempitem.misc10 = 0;
8848 184 tempitem.wpn = 0;
8849 184 tempitem.wpn2 = 0;
8850 184 tempitem.wpn3 = 0;
8851 184 tempitem.wpn4 = 0;
8852 184 tempitem.wpn5 = 0;
8853 184 tempitem.wpn6 = 0;
8854 184 tempitem.wpn7 = 0;
8855 184 tempitem.wpn8 = 0;
8856 184 tempitem.wpn9 = 0;
8857 184 tempitem.wpn10 = 0;
8858 184 break;
8859 }
8860 case itype_perilscroll:
8861 {
8862 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8863 92 tempitem.misc2 = 0;
8864 92 tempitem.misc3 = 0;
8865 92 tempitem.misc4 = 0;
8866 92 tempitem.misc5 = 0;
8867 92 tempitem.misc6 = 0;
8868 92 tempitem.misc7 = 0;
8869 92 tempitem.misc8 = 0;
8870 92 tempitem.misc9 = 0;
8871 92 tempitem.misc10 = 0;
8872 92 tempitem.wpn = 0;
8873 92 tempitem.wpn2 = 0;
8874 92 tempitem.wpn3 = 0;
8875 92 tempitem.wpn4 = 0;
8876 92 tempitem.wpn5 = 0;
8877 92 tempitem.wpn6 = 0;
8878 92 tempitem.wpn7 = 0;
8879 92 tempitem.wpn8 = 0;
8880 92 tempitem.wpn9 = 0;
8881 92 tempitem.wpn10 = 0;
8882 92 break;
8883 }
8884 case itype_wealthmedal:
8885 {
8886 277 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8887 277 tempitem.misc2 = 0;
8888 277 tempitem.misc3 = 0;
8889 277 tempitem.misc4 = 0;
8890 277 tempitem.misc5 = 0;
8891 277 tempitem.misc6 = 0;
8892 277 tempitem.misc7 = 0;
8893 277 tempitem.misc8 = 0;
8894 277 tempitem.misc9 = 0;
8895 277 tempitem.misc10 = 0;
8896 277 tempitem.wpn = 0;
8897 277 tempitem.wpn2 = 0;
8898 277 tempitem.wpn3 = 0;
8899 277 tempitem.wpn4 = 0;
8900 277 tempitem.wpn5 = 0;
8901 277 tempitem.wpn6 = 0;
8902 277 tempitem.wpn7 = 0;
8903 277 tempitem.wpn8 = 0;
8904 277 tempitem.wpn9 = 0;
8905 277 tempitem.wpn10 = 0;
8906 277 break;
8907 }
8908 case itype_heartring:
8909 {
8910 278 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8911 278 tempitem.misc3 = 0;
8912 278 tempitem.misc4 = 0;
8913 278 tempitem.misc5 = 0;
8914 278 tempitem.misc6 = 0;
8915 278 tempitem.misc7 = 0;
8916 278 tempitem.misc8 = 0;
8917 278 tempitem.misc9 = 0;
8918 278 tempitem.misc10 = 0;
8919 278 tempitem.wpn = 0;
8920 278 tempitem.wpn2 = 0;
8921 278 tempitem.wpn3 = 0;
8922 278 tempitem.wpn4 = 0;
8923 278 tempitem.wpn5 = 0;
8924 278 tempitem.wpn6 = 0;
8925 278 tempitem.wpn7 = 0;
8926 278 tempitem.wpn8 = 0;
8927 278 tempitem.wpn9 = 0;
8928 278 tempitem.wpn10 = 0;
8929 278 break;
8930 }
8931 case itype_magicring:
8932 {
8933 372 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8934 372 tempitem.misc3 = 0;
8935 372 tempitem.misc4 = 0;
8936 372 tempitem.misc5 = 0;
8937 372 tempitem.misc6 = 0;
8938 372 tempitem.misc7 = 0;
8939 372 tempitem.misc8 = 0;
8940 372 tempitem.misc9 = 0;
8941 372 tempitem.misc10 = 0;
8942 372 tempitem.wpn = 0;
8943 372 tempitem.wpn2 = 0;
8944 372 tempitem.wpn3 = 0;
8945 372 tempitem.wpn4 = 0;
8946 372 tempitem.wpn5 = 0;
8947 372 tempitem.wpn6 = 0;
8948 372 tempitem.wpn7 = 0;
8949 372 tempitem.wpn8 = 0;
8950 372 tempitem.wpn9 = 0;
8951 372 tempitem.wpn10 = 0;
8952 372 break;
8953 }
8954 case itype_spinscroll2:
8955 {
8956 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8957 92 tempitem.misc2 = 0;
8958 92 tempitem.misc3 = 0;
8959 92 tempitem.misc4 = 0;
8960 92 tempitem.misc5 = 0;
8961 92 tempitem.misc6 = 0;
8962 92 tempitem.misc7 = 0;
8963 92 tempitem.misc8 = 0;
8964 92 tempitem.misc9 = 0;
8965 92 tempitem.misc10 = 0;
8966 92 tempitem.wpn = 0;
8967 92 tempitem.wpn2 = 0;
8968 92 tempitem.wpn3 = 0;
8969 92 tempitem.wpn4 = 0;
8970 92 tempitem.wpn5 = 0;
8971 92 tempitem.wpn6 = 0;
8972 92 tempitem.wpn7 = 0;
8973 92 tempitem.wpn8 = 0;
8974 92 tempitem.wpn9 = 0;
8975 92 tempitem.wpn10 = 0;
8976 92 break;
8977 }
8978 case itype_quakescroll2:
8979 {
8980 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8981 92 tempitem.misc3 = 0;
8982 92 tempitem.misc4 = 0;
8983 92 tempitem.misc5 = 0;
8984 92 tempitem.misc6 = 0;
8985 92 tempitem.misc7 = 0;
8986 92 tempitem.misc8 = 0;
8987 92 tempitem.misc9 = 0;
8988 92 tempitem.misc10 = 0;
8989 92 tempitem.wpn = 0;
8990 92 tempitem.wpn2 = 0;
8991 92 tempitem.wpn3 = 0;
8992 92 tempitem.wpn4 = 0;
8993 92 tempitem.wpn5 = 0;
8994 92 tempitem.wpn6 = 0;
8995 92 tempitem.wpn7 = 0;
8996 92 tempitem.wpn8 = 0;
8997 92 tempitem.wpn9 = 0;
8998 92 tempitem.wpn10 = 0;
8999 92 break;
9000 }
9001 case itype_agony:
9002 {
9003 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9004 92 tempitem.misc2 = 0;
9005 92 tempitem.misc3 = 0;
9006 92 tempitem.misc4 = 0;
9007 92 tempitem.misc5 = 0;
9008 92 tempitem.misc6 = 0;
9009 92 tempitem.misc7 = 0;
9010 92 tempitem.misc8 = 0;
9011 92 tempitem.misc9 = 0;
9012 92 tempitem.misc10 = 0;
9013 92 tempitem.wpn = 0;
9014 92 tempitem.wpn2 = 0;
9015 92 tempitem.wpn3 = 0;
9016 92 tempitem.wpn4 = 0;
9017 92 tempitem.wpn5 = 0;
9018 92 tempitem.wpn6 = 0;
9019 92 tempitem.wpn7 = 0;
9020 92 tempitem.wpn8 = 0;
9021 92 tempitem.wpn9 = 0;
9022 92 tempitem.wpn10 = 0;
9023 92 break;
9024 }
9025 case itype_stompboots:
9026 {
9027 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9028 92 tempitem.misc1 = 0;
9029 92 tempitem.misc2 = 0;
9030 92 tempitem.misc3 = 0;
9031 92 tempitem.misc4 = 0;
9032 92 tempitem.misc5 = 0;
9033 92 tempitem.misc6 = 0;
9034 92 tempitem.misc7 = 0;
9035 92 tempitem.misc8 = 0;
9036 92 tempitem.misc9 = 0;
9037 92 tempitem.misc10 = 0;
9038 92 tempitem.wpn = 0;
9039 92 tempitem.wpn2 = 0;
9040 92 tempitem.wpn3 = 0;
9041 92 tempitem.wpn4 = 0;
9042 92 tempitem.wpn5 = 0;
9043 92 tempitem.wpn6 = 0;
9044 92 tempitem.wpn7 = 0;
9045 92 tempitem.wpn8 = 0;
9046 92 tempitem.wpn9 = 0;
9047 92 tempitem.wpn10 = 0;
9048 92 break;
9049 }
9050 case itype_whimsicalring:
9051 {
9052 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9053 92 tempitem.misc2 = 0;
9054 92 tempitem.misc3 = 0;
9055 92 tempitem.misc4 = 0;
9056 92 tempitem.misc5 = 0;
9057 92 tempitem.misc6 = 0;
9058 92 tempitem.misc7 = 0;
9059 92 tempitem.misc8 = 0;
9060 92 tempitem.misc9 = 0;
9061 92 tempitem.misc10 = 0;
9062 92 tempitem.wpn = 0;
9063 92 tempitem.wpn2 = 0;
9064 92 tempitem.wpn3 = 0;
9065 92 tempitem.wpn4 = 0;
9066 92 tempitem.wpn5 = 0;
9067 92 tempitem.wpn6 = 0;
9068 92 tempitem.wpn7 = 0;
9069 92 tempitem.wpn8 = 0;
9070 92 tempitem.wpn9 = 0;
9071 92 tempitem.wpn10 = 0;
9072 92 break;
9073 }
9074 case itype_perilring:
9075 {
9076 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9077 93 tempitem.misc2 = 0;
9078 93 tempitem.misc3 = 0;
9079 93 tempitem.misc4 = 0;
9080 93 tempitem.misc5 = 0;
9081 93 tempitem.misc6 = 0;
9082 93 tempitem.misc7 = 0;
9083 93 tempitem.misc8 = 0;
9084 93 tempitem.misc9 = 0;
9085 93 tempitem.misc10 = 0;
9086 93 tempitem.wpn = 0;
9087 93 tempitem.wpn2 = 0;
9088 93 tempitem.wpn3 = 0;
9089 93 tempitem.wpn4 = 0;
9090 93 tempitem.wpn5 = 0;
9091 93 tempitem.wpn6 = 0;
9092 93 tempitem.wpn7 = 0;
9093 93 tempitem.wpn8 = 0;
9094 93 tempitem.wpn9 = 0;
9095 93 tempitem.wpn10 = 0;
9096 93 break;
9097 }
9098 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9099 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9100 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9101 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9102 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9103 {
9104 2541 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9105 2541 tempitem.misc1 = 0;
9106 2541 tempitem.misc2 = 0;
9107 2541 tempitem.misc3 = 0;
9108 2541 tempitem.misc4 = 0;
9109 2541 tempitem.misc5 = 0;
9110 2541 tempitem.misc6 = 0;
9111 2541 tempitem.misc7 = 0;
9112 2541 tempitem.misc8 = 0;
9113 2541 tempitem.misc9 = 0;
9114 2541 tempitem.misc10 = 0;
9115 2541 tempitem.wpn = 0;
9116 2541 tempitem.wpn2 = 0;
9117 2541 tempitem.wpn3 = 0;
9118 2541 tempitem.wpn4 = 0;
9119 2541 tempitem.wpn5 = 0;
9120 2541 tempitem.wpn6 = 0;
9121 2541 tempitem.wpn7 = 0;
9122 2541 tempitem.wpn8 = 0;
9123 2541 tempitem.wpn9 = 0;
9124 2541 tempitem.wpn10 = 0;
9125 2541 break;
9126 }
9127 }
9128 23808 }
9129 //Port quest rules to items
9130
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version <= 31)
9131 {
9132
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_bomb)
9133 {
9134
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 90 times.
107 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9135 90 else tempitem.flags &= ~ ITEM_FLAG2;
9136 107 }
9137
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23609 times.
23701 else if(tempitem.family == itype_sbomb)
9138 {
9139
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 75 times.
92 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9140 75 else tempitem.flags &= ~ ITEM_FLAG2;
9141 92 }
9142
9143
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 23332 times.
23609 else if(tempitem.family == itype_brang)
9144 {
9145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 277 times.
277 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9146 277 else tempitem.flags &= ~ ITEM_FLAG4;
9147 277 }
9148
2/2
✓ Branch 0 taken 23225 times.
✓ Branch 1 taken 107 times.
23332 else if(tempitem.family == itype_wand)
9149 {
9150
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9151 105 else tempitem.flags &= ~ ITEM_FLAG3;
9152 107 }
9153 23808 }
9154
9155 //Port quest rules to items
9156
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version <= 37)
9157 {
9158
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23715 times.
23808 if(tempitem.family == itype_flippers)
9159 {
9160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9161 93 else tempitem.flags &= ~ ITEM_FLAG1;
9162 93 }
9163
2/2
✓ Branch 0 taken 15904 times.
✓ Branch 1 taken 7811 times.
23715 else if(tempitem.family == itype_sword)
9164 {
9165
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9166 7742 else tempitem.flags &= ~ ITEM_FLAG5;
9167 7811 }
9168
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 15797 times.
15904 else if(tempitem.family == itype_wand)
9169 {
9170
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 104 times.
107 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9171 104 else tempitem.flags &= ~ ITEM_FLAG5;
9172 107 }
9173
4/4
✓ Branch 0 taken 15690 times.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 15468 times.
15797 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9174 {
9175 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9176
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 257 times.
329 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9177 257 else tempitem.flags &= ~ ITEM_FLAG3;
9178 329 }
9179 23808 }
9180
9181
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 38)
9182 {
9183
4/4
✓ Branch 0 taken 23531 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 23347 times.
23808 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9184 {
9185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9186 461 else tempitem.flags &= ~ITEM_FLAG4;
9187
9188
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 450 times.
461 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9189 450 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9190 461 }
9191
2/2
✓ Branch 0 taken 23073 times.
✓ Branch 1 taken 274 times.
23347 else if(tempitem.family == itype_arrow)
9192 {
9193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274 times.
274 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9194 274 else tempitem.flags &= ~ITEM_FLAG4;
9195
9196
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 270 times.
274 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9197 270 else tempitem.flags |= ITEM_FLAG2;
9198 274 }
9199 23808 }
9200
9201
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 39)
9202 {
9203
6/6
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 23609 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 222 times.
✓ Branch 5 taken 23387 times.
23808 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9204 {
9205
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 409 times.
421 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9206 409 else tempitem.flags &= ~ITEM_FLAG5;
9207 421 }
9208
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 23204 times.
23387 else if(tempitem.family == itype_potion)
9209 {
9210
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 159 times.
183 if(get_qr(qr_NONBUBBLEMEDICINE))
9211 {
9212 24 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9213 24 }
9214 else
9215 {
9216 159 tempitem.flags |= ITEM_FLAG3;
9217
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 74 times.
159 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9218 74 else tempitem.flags &= ~ITEM_FLAG4;
9219 }
9220 183 }
9221
2/2
✓ Branch 0 taken 23020 times.
✓ Branch 1 taken 184 times.
23204 else if(tempitem.family == itype_triforcepiece)
9222 {
9223
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 154 times.
184 if(get_qr(qr_NONBUBBLETRIFORCE))
9224 {
9225 30 tempitem.flags |= ITEM_FLAG3;
9226
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 24 times.
30 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9227 24 else tempitem.flags &= ~ITEM_FLAG4;
9228 30 }
9229 else
9230 {
9231 154 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9232 }
9233 184 }
9234 23808 }
9235
9236
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 40)
9237 {
9238
4/4
✓ Branch 0 taken 23506 times.
✓ Branch 1 taken 302 times.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 23413 times.
23808 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9239 {
9240
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 348 times.
395 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9241 348 else tempitem.flags &= ~ITEM_FLAG1;
9242 395 }
9243
8/8
✓ Branch 0 taken 23191 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 15380 times.
✓ Branch 3 taken 7811 times.
✓ Branch 4 taken 15273 times.
✓ Branch 5 taken 107 times.
✓ Branch 6 taken 92 times.
✓ Branch 7 taken 15181 times.
23413 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9244 {
9245
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 8151 times.
8232 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9246 8151 else tempitem.flags &= ~ITEM_FLAG8;
9247 8232 }
9248
6/6
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 15890 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 93 times.
✓ Branch 5 taken 15797 times.
23808 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9249 {
9250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9251 8011 else tempitem.flags &= ~ITEM_FLAG7;
9252 8011 }
9253
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 92 times.
15797 else if(tempitem.family == itype_cbyrna)
9254 {
9255 92 tempitem.flags |= ITEM_FLAG7;
9256 92 }
9257 23808 }
9258
9259
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 41 )
9260 {
9261
2/2
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
23808 if(tempitem.family == itype_sword)
9262 {
9263
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9264 7742 else tempitem.flags &= ~ITEM_FLAG9;
9265
9266
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9267 7742 else tempitem.flags &= ~ITEM_FLAG10;
9268 7811 }
9269 23808 }
9270
9271
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 42 )
9272 {
9273
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_wand)
9274 {
9275
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9276 105 else tempitem.flags &= ~ITEM_FLAG3;
9277
9278 107 tempitem.flags &= ~ITEM_FLAG6;
9279 107 }
9280
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23608 times.
23701 else if(tempitem.family == itype_hammer)
9281 {
9282 93 tempitem.flags &= ~ITEM_FLAG3;
9283 93 }
9284
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23516 times.
23608 else if(tempitem.family == itype_cbyrna)
9285 {
9286 92 tempitem.flags |= ITEM_FLAG3;
9287
9288 92 tempitem.flags &= ~ITEM_FLAG6;
9289 92 }
9290
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 7811 times.
23516 else if(tempitem.family == itype_sword)
9291 {
9292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7811 times.
7811 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9293 7811 else tempitem.flags &= ~ITEM_FLAG6;
9294 7811 }
9295 23808 }
9296
9297
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 43 )
9298 {
9299
2/2
✓ Branch 0 taken 23670 times.
✓ Branch 1 taken 138 times.
23808 if(tempitem.family == itype_whistle)
9300 {
9301
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 135 times.
138 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9302 135 else tempitem.flags &= ~ITEM_FLAG3;
9303 138 }
9304 23808 }
9305
9306
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 45 )
9307 {
9308
2/2
✓ Branch 0 taken 23715 times.
✓ Branch 1 taken 93 times.
23808 if(tempitem.family == itype_flippers)
9309 {
9310 93 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9311 93 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9312 93 }
9313 23808 }
9314
9315
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 46 )
9316 {
9317
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if(tempitem.family == itype_raft)
9318 {
9319 92 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9320 92 }
9321 23808 }
9322
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if ( s_version < 34 ) //! set the default counter for older quests.
9323 {
9324
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 23733 times.
23808 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9325 {
9326 75 tempitem.cost_counter[0] = 1;
9327 75 }
9328 else
9329 {
9330
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 19125 times.
23733 if(get_qr(qr_ENABLEMAGIC))
9331 4608 tempitem.cost_counter[0] = 4;
9332 else
9333 {
9334 19125 tempitem.cost_amount[0] = 0;
9335 19125 tempitem.cost_counter[0] = -1;
9336 }
9337 }
9338 23808 }
9339
9340
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if ( s_version < 35 ) //new Lens of Truth flags
9341 {
9342
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if ( tempitem.family == itype_lens )
9343 {
9344
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 3 times.
92 if ( get_qr(qr_RAFTLENS) )
9345 {
9346 3 tempitem.flags |= ITEM_FLAG4;
9347 3 }
9348
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 52 times.
92 if ( get_qr(qr_LENSHINTS) )
9349 {
9350 52 tempitem.flags |= ITEM_FLAG1;
9351 52 }
9352
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 4 times.
92 if ( get_qr(qr_LENSSEESENEMIES) )
9353 {
9354 4 tempitem.flags |= ITEM_FLAG5;
9355 4 }
9356 92 }
9357 23808 }
9358
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9359 {
9360
2/2
✓ Branch 0 taken 190464 times.
✓ Branch 1 taken 23808 times.
214272 for ( int32_t q = 0; q < 8; q++ )
9361 {
9362 190464 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9363 190464 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9364 190464 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9365 190464 tempitem.sprite_initiald[q] = 0;
9366 190464 }
9367
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 23808 times.
71424 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9368 23808 tempitem.sprite_script = 0;
9369 23808 }
9370
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9371 {
9372 23808 tempitem.pickupflag = 0;
9373 23808 }
9374
9375
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 51 )
9376 {
9377
2/2
✓ Branch 0 taken 23586 times.
✓ Branch 1 taken 222 times.
23808 if( tempitem.family == itype_candle )
9378 {
9379 222 tempitem.misc4 = 50; //Step speed
9380 222 }
9381 23808 }
9382
9383
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 52 )
9384 {
9385
2/2
✓ Branch 0 taken 23525 times.
✓ Branch 1 taken 283 times.
23808 if( tempitem.family == itype_shield )
9386 283 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9387 23808 }
9388
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if(s_version < 53)
9389 {
9390
4/4
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23335 times.
✓ Branch 2 taken 274 times.
✓ Branch 3 taken 92 times.
23808 switch(tempitem.family)
9391 {
9392 case itype_arrow:
9393 274 tempitem.cost_counter[1] = crARROWS;
9394 274 tempitem.cost_amount[1] = 1;
9395 274 break;
9396 case itype_bomb:
9397 107 tempitem.cost_counter[1] = crBOMBS;
9398 107 tempitem.cost_amount[1] = 1;
9399 107 break;
9400 case itype_sbomb:
9401 92 tempitem.cost_counter[1] = crSBOMBS;
9402 92 tempitem.cost_amount[1] = 1;
9403 92 break;
9404 default:
9405 23335 tempitem.cost_counter[1] = crNONE;
9406 23335 tempitem.cost_amount[1] = 0;
9407 23335 }
9408 23808 tempitem.magiccosttimer[1] = 0;
9409 23808 }
9410
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 25088 times.
33280 if( s_version < 54 )
9411 {
9412
2/2
✓ Branch 0 taken 24989 times.
✓ Branch 1 taken 99 times.
25088 if( tempitem.family == itype_flippers )
9413 99 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9414 25088 }
9415
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 25088 times.
33280 if(s_version < 55)
9416 {
9417
3/3
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 24700 times.
25088 switch(tempitem.family)
9418 {
9419 case itype_spinscroll:
9420 case itype_quakescroll:
9421 194 tempitem.usesound2 = WAV_ZN1CHARGE;
9422 194 break;
9423 case itype_spinscroll2:
9424 case itype_quakescroll2:
9425 194 tempitem.usesound2 = WAV_ZN1CHARGE2;
9426 194 break;
9427 }
9428 25088 }
9429
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 25088 times.
33280 if(s_version < 56)
9430 {
9431
4/4
✓ Branch 0 taken 24645 times.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 234 times.
✓ Branch 3 taken 112 times.
25088 switch(tempitem.family)
9432 {
9433 case itype_divinefire:
9434
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 5 times.
97 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9435
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 81 times.
97 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9436 97 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9437 97 break;
9438 case itype_candle:
9439
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 120 times.
234 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9440 234 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9441 234 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9442 234 break;
9443 case itype_book:
9444 112 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9445 112 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9446 112 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9447 112 break;
9448 }
9449 25088 }
9450
9451
2/2
✓ Branch 0 taken 31136 times.
✓ Branch 1 taken 2144 times.
33280 if(tempitem.fam_type==0) // Always do this
9452 2144 tempitem.fam_type=1;
9453
9454 33280 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9455 33280 }
9456
9457 130 return 0;
9458 130 }
9459
9460 static bool did_init_def_items = false;
9461 66752 void init_def_items()
9462 {
9463
2/2
✓ Branch 0 taken 66636 times.
✓ Branch 1 taken 116 times.
66752 if(did_init_def_items) return;
9464 116 did_init_def_items = true;
9465 116 default_items[3].cost_counter[1] = crBOMBS;
9466 116 default_items[13].cost_counter[1] = crARROWS;
9467 116 default_items[14].cost_counter[1] = crARROWS;
9468 116 default_items[48].cost_counter[1] = crSBOMBS;
9469 116 default_items[57].cost_counter[1] = crARROWS;
9470 66752 }
9471 66752 void reset_itembuf(itemdata *item, int32_t id)
9472 {
9473 66752 init_def_items();
9474
2/2
✓ Branch 0 taken 28476 times.
✓ Branch 1 taken 38276 times.
66752 if(id<iLast)
9475 {
9476 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9477 38276 word tile = item->tile;
9478 38276 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9479 38276 int32_t ltm = item->ltm;
9480
9481 38276 memcpy(item,&default_items[id],sizeof(itemdata));
9482 38276 item->tile = tile;
9483 38276 item->misc_flags = miscs;
9484 38276 item->csets = cset;
9485 38276 item->frames = frames;
9486 38276 item->speed = speed;
9487 38276 item->delay = delay;
9488 38276 item->ltm = ltm;
9489 38276 }
9490 66752 }
9491
9492 33792 void reset_itemname(int32_t id)
9493 {
9494 33792 sprintf(item_string[id],"zz%03d",id);
9495
9496
2/2
✓ Branch 0 taken 14916 times.
✓ Branch 1 taken 18876 times.
33792 if(id < iLast)
9497 18876 strcpy(item_string[id],old_item_string[id]);
9498 33792 }
9499
9500 130 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9501 {
9502 130 word weapons_to_read=MAXWPNS;
9503 int32_t dummy;
9504 byte padding;
9505 wpndata tempweapon;
9506 130 word s_version=0, s_cversion=0;
9507
9508
9509
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(Header->zelda_version < 0x186)
9510 {
9511 weapons_to_read=64;
9512 }
9513
9514
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(Header->zelda_version < 0x185)
9515 {
9516 weapons_to_read=32;
9517 }
9518
9519
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version > 0x192)
9520 {
9521 126 weapons_to_read=0;
9522
9523 //section version info
9524
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_version,f))
9525 {
9526 return qe_invalid;
9527 }
9528
9529 126 FFCore.quest_format[vWeaponSprites] = s_version;
9530
9531 //al_trace("Weapons version %d\n", s_version);
9532
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_cversion,f))
9533 {
9534 return qe_invalid;
9535 }
9536
9537 //section size
9538
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy,f))
9539 {
9540 return qe_invalid;
9541 }
9542
9543 //finally... section data
9544
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&weapons_to_read,f))
9545 {
9546 return qe_invalid;
9547 }
9548
9549
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if (!(weapons_to_read >= 0 && weapons_to_read <= MAXWPNS))
9550 {
9551 return qe_invalid;
9552 }
9553 126 }
9554
9555
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version>2)
9556 {
9557
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<weapons_to_read; i++)
9558 {
9559 char tempname[64];
9560
9561
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!pfread(tempname, 64, f))
9562 {
9563 return qe_invalid;
9564 }
9565
9566 29184 weapon_string[i][0] = '\0';
9567 29184 strncat(weapon_string[i], tempname, 64 - 1);
9568 29184 }
9569
9570
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(s_version<4)
9571 {
9572 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9573 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9574 }
9575
9576
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(s_version<5)
9577 {
9578 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9579 }
9580
9581 /*
9582 if (s_version<6)
9583 {
9584 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9585 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9586 }
9587 */
9588 114 }
9589 else
9590 {
9591
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXWPNS; i++)
9592 4096 reset_weaponname(i);
9593 }
9594
9595
2/2
✓ Branch 0 taken 31024 times.
✓ Branch 1 taken 130 times.
31154 for(int32_t i=0; i<weapons_to_read; i++)
9596 {
9597 31024 word oldtile = 0;
9598
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 22064 times.
31024 if (s_version < 8)
9599 {
9600
1/2
✓ Branch 0 taken 22064 times.
✗ Branch 1 not taken.
22064 if (!p_igetw(&oldtile, f))
9601 return qe_invalid;
9602 22064 }
9603
9604
1/2
✓ Branch 0 taken 31024 times.
✗ Branch 1 not taken.
31024 if(!p_getc(&tempweapon.misc,f))
9605 {
9606 return qe_invalid;
9607 }
9608
9609
1/2
✓ Branch 0 taken 31024 times.
✗ Branch 1 not taken.
31024 if(!p_getc(&tempweapon.csets,f))
9610 {
9611 return qe_invalid;
9612 }
9613
9614
1/2
✓ Branch 0 taken 31024 times.
✗ Branch 1 not taken.
31024 if(!p_getc(&tempweapon.frames,f))
9615 {
9616 return qe_invalid;
9617 }
9618
9619
1/2
✓ Branch 0 taken 31024 times.
✗ Branch 1 not taken.
31024 if(!p_getc(&tempweapon.speed,f))
9620 {
9621 return qe_invalid;
9622 }
9623
9624
1/2
✓ Branch 0 taken 31024 times.
✗ Branch 1 not taken.
31024 if(!p_getc(&tempweapon.type,f))
9625 {
9626 return qe_invalid;
9627 }
9628
9629
2/2
✓ Branch 0 taken 21552 times.
✓ Branch 1 taken 9472 times.
31024 if ( s_version >= 7 )
9630 {
9631
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetw(&tempweapon.script,f))
9632 {
9633 return qe_invalid;
9634 }
9635
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempweapon.tile,f))
9636 {
9637 return qe_invalid;
9638 }
9639 9472 }
9640
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 21552 times.
31024 if ( s_version < 7 )
9641 {
9642 21552 tempweapon.tile = oldtile;
9643 21552 }
9644
9645
2/2
✓ Branch 0 taken 30000 times.
✓ Branch 1 taken 1024 times.
31024 if(Header->zelda_version < 0x193)
9646 {
9647
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
9648 {
9649 return qe_invalid;
9650 }
9651 1024 }
9652
9653
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 1840 times.
31024 if(s_version < 6)
9654 {
9655
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1836 times.
1840 if(i==ewFIRETRAIL)
9656 {
9657 4 tempweapon.misc |= WF_BEHIND;
9658 4 }
9659 else
9660 1836 tempweapon.misc &= ~WF_BEHIND;
9661 1840 }
9662
9663 31024 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9664 31024 }
9665
9666
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<2)
9667 {
9668 16 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9669 16 }
9670
9671
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<5)
9672 {
9673 16 wpnsbuf[iwQuarterHearts].tile=1;
9674 16 wpnsbuf[iwQuarterHearts].csets=1;
9675 16 }
9676
9677
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(Header->zelda_version < 0x176)
9678 {
9679 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9680 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9681 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9682 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9683 }
9684
9685
2/4
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
130 if((Header->zelda_version < 0x192)||
9686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9687 {
9688 4 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9689 4 }
9690
9691
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if((Header->zelda_version < 0x210))
9692 {
9693 4 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9694 4 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9695 4 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9696 4 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9697 4 }
9698
9699 130 return 0;
9700 130 }
9701
9702 130 void init_guys(int32_t guyversion)
9703 {
9704
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 130 times.
66690 for(int32_t i=0; i<MAXGUYS; i++)
9705 {
9706 66560 guysbuf[i] = default_guys[0];
9707 66560 }
9708
9709
2/2
✓ Branch 0 taken 23010 times.
✓ Branch 1 taken 130 times.
23140 for(int32_t i=0; i<OLDMAXGUYS; i++)
9710 {
9711 23010 guysbuf[i] = default_guys[i];
9712
2/2
✓ Branch 0 taken 22750 times.
✓ Branch 1 taken 260 times.
23010 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9713 23010 guysbuf[i].spr_death = iwDeath;
9714 23010 guysbuf[i].spr_spawn = iwSpawn;
9715 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9716
4/4
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 20178 times.
✓ Branch 2 taken 2816 times.
✓ Branch 3 taken 16 times.
23010 if(guyversion<=3 && i==ePATRABS)
9717 {
9718 16 guysbuf[i].bosspal=spDIG;
9719 16 guysbuf[i].cset=14;
9720 16 guysbuf[i].misc9=14;
9721 16 }
9722
9723
2/2
✓ Branch 0 taken 20178 times.
✓ Branch 1 taken 2832 times.
23010 if(guyversion<=3)
9724 {
9725 // Rope/Ghini Flash rules
9726
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 2124 times.
2832 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9727 {
9728
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
2124 if(i==eROPE2)
9729 {
9730 12 guysbuf[i].flags2 &= ~guy_flashing;
9731 12 }
9732 2124 }
9733
9734
2/2
✓ Branch 0 taken 2301 times.
✓ Branch 1 taken 531 times.
2832 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9735 {
9736
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9737 {
9738 18 guysbuf[i].flags2 &= ~guy_flashing;
9739 18 }
9740 531 }
9741
9742
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 16 times.
2832 if(i==eGHINI2)
9743 {
9744
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
16 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9745 {
9746 3 guysbuf[i].flags2 |= guy_blinking;
9747 3 }
9748
9749
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9750 {
9751 guysbuf[i].flags2 |= guy_transparent;
9752 }
9753 16 }
9754 2832 }
9755
9756 // Darknut fix
9757
10/10
✓ Branch 0 taken 22880 times.
✓ Branch 1 taken 130 times.
✓ Branch 2 taken 22750 times.
✓ Branch 3 taken 130 times.
✓ Branch 4 taken 22620 times.
✓ Branch 5 taken 130 times.
✓ Branch 6 taken 22490 times.
✓ Branch 7 taken 130 times.
✓ Branch 8 taken 130 times.
✓ Branch 9 taken 22360 times.
23010 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9758 {
9759
2/2
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 210 times.
650 if(get_qr(qr_NEWENEMYTILES))
9760 {
9761 440 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9762 440 guysbuf[i].s_width=guysbuf[i].e_width;
9763 440 guysbuf[i].s_height=guysbuf[i].e_height;
9764 440 }
9765 210 else guysbuf[i].s_tile=860;
9766
9767
2/2
✓ Branch 0 taken 570 times.
✓ Branch 1 taken 80 times.
650 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9768 {
9769 80 guysbuf[i].flags |= guy_bkshield;
9770 80 }
9771 650 }
9772
9773
4/4
✓ Branch 0 taken 22880 times.
✓ Branch 1 taken 130 times.
✓ Branch 2 taken 23002 times.
✓ Branch 3 taken 8 times.
23010 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9774 {
9775 8 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9776 8 }
9777 23010 }
9778 130 }
9779
9780 4096 void reset_weaponname(int32_t i)
9781 {
9782
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 2688 times.
4096 if(i<wLast)
9783 {
9784 1408 strcpy(weapon_string[i],old_weapon_string[i]);
9785 1408 }
9786 else
9787 2688 sprintf(weapon_string[i],"zz%03d",i);
9788 4096 }
9789
9790 130 void init_item_drop_sets()
9791 {
9792
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9793 {
9794 // item_drop_sets[i] = default_item_drop_sets[0];
9795 33280 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9796 33280 }
9797
9798
2/2
✓ Branch 0 taken 1690 times.
✓ Branch 1 taken 130 times.
1820 for(int32_t i=0; i<isMAX; i++)
9799 {
9800 1690 item_drop_sets[i] = default_item_drop_sets[i];
9801
9802 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9803
2/2
✓ Branch 0 taken 16900 times.
✓ Branch 1 taken 1690 times.
18590 for(int32_t j=0; j<10; ++j)
9804 {
9805 16900 int32_t it = item_drop_sets[i].item[j];
9806
9807
3/4
✓ Branch 0 taken 11868 times.
✓ Branch 1 taken 5032 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 762 times.
16900 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9808
2/2
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 11106 times.
11868 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9809 {
9810 762 item_drop_sets[i].chance[j+1]=0;
9811 762 }
9812
3/4
✓ Branch 0 taken 520 times.
✓ Branch 1 taken 15618 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 520 times.
16138 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9813 {
9814 item_drop_sets[i].chance[j+1]=0;
9815 }
9816
9817 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9818
2/2
✓ Branch 0 taken 16892 times.
✓ Branch 1 taken 8 times.
16900 if(itemsbuf[it].family == itype_misc)
9819 {
9820 // If a non-gameplay item was selected, then item drop was aborted.
9821 // Reflect this by increasing the 'Nothing' chance accordingly.
9822 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9823 8 item_drop_sets[i].chance[j+1]=0;
9824 8 }
9825 16900 }
9826 1690 }
9827 130 }
9828
9829 130 void init_favorites()
9830 {
9831
2/2
✓ Branch 0 taken 163800 times.
✓ Branch 1 taken 130 times.
163930 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9832 {
9833 163800 favorite_combos[i]=-1;
9834 163800 }
9835 130 }
9836
9837 const char *ctype_name[cMAX]=
9838 {
9839 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9840 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9841 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9842 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9843 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9844 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9845 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9846 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9847 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9848 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9849 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9850 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9851 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9852 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9853 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9854 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9855 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9856 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9857 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9858 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9859 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9860 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9861 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9862 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9863 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9864 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9865 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9866 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9867
9868 };
9869
9870 225 int32_t init_combo_classes()
9871 {
9872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 225 times.
225 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9873
2/2
✓ Branch 0 taken 40950 times.
✓ Branch 1 taken 225 times.
41175 for(int32_t i=0; i<cMAX; i++)
9874 {
9875 40950 combo_class_buf[i] = default_combo_classes[i];
9876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40950 times.
40950 if ( char const* nm = zi->getComboTypeName(i) )
9877 {
9878 40950 size_t len = strlen(nm);
9879
2/2
✓ Branch 0 taken 2620800 times.
✓ Branch 1 taken 40950 times.
2661750 for ( size_t q = 0; q < 64; q++ )
9880 {
9881
2/2
✓ Branch 0 taken 601200 times.
✓ Branch 1 taken 2019600 times.
2620800 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9882 2620800 }
9883 40950 }
9884 40950 }
9885
9886 225 return 0;
9887 }
9888
9889 97 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
9890 {
9891
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 assert(v_herosprites < 6);
9892 //these are here to bypass compiler warnings about unused arguments
9893 97 cv_herosprites=cv_herosprites;
9894
9895 97 zinit.hero_swim_speed=67; //default
9896 97 setupherotiles(zinit.heroAnimationStyle);
9897 97 setupherodefenses();
9898 97 setupherooffsets();
9899
9900
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 77 times.
97 if(v_herosprites>=0)
9901 {
9902 word tile, tile2;
9903 byte flip, extend, dummy_byte;
9904
9905
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
9906 {
9907
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
9908 {
9909 return qe_invalid;
9910 }
9911
9912
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
9913 {
9914 return qe_invalid;
9915 }
9916
9917
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
9918 {
9919 return qe_invalid;
9920 }
9921
9922 308 walkspr[i][spr_tile]=(int32_t)tile;
9923 308 walkspr[i][spr_flip]=(int32_t)flip;
9924 308 walkspr[i][spr_extend]=(int32_t)extend;
9925 308 }
9926
9927
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
9928 {
9929
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
9930 {
9931 return qe_invalid;
9932 }
9933
9934
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
9935 {
9936 return qe_invalid;
9937 }
9938
9939
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
9940 {
9941 return qe_invalid;
9942 }
9943
9944 308 stabspr[i][spr_tile]=(int32_t)tile;
9945 308 stabspr[i][spr_flip]=(int32_t)flip;
9946 308 stabspr[i][spr_extend]=(int32_t)extend;
9947 308 }
9948
9949
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
9950 {
9951
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
9952 {
9953 return qe_invalid;
9954 }
9955
9956
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
9957 {
9958 return qe_invalid;
9959 }
9960
9961
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
9962 {
9963 return qe_invalid;
9964 }
9965
9966 308 slashspr[i][spr_tile]=(int32_t)tile;
9967 308 slashspr[i][spr_flip]=(int32_t)flip;
9968 308 slashspr[i][spr_extend]=(int32_t)extend;
9969 308 }
9970
9971
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
9972 {
9973
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
9974 {
9975 return qe_invalid;
9976 }
9977
9978
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
9979 {
9980 return qe_invalid;
9981 }
9982
9983
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
9984 {
9985 return qe_invalid;
9986 }
9987
9988 308 floatspr[i][spr_tile]=(int32_t)tile;
9989 308 floatspr[i][spr_flip]=(int32_t)flip;
9990 308 floatspr[i][spr_extend]=(int32_t)extend;
9991 308 }
9992
9993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>1)
9994 {
9995
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
9996 {
9997
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
9998 {
9999 return qe_invalid;
10000 }
10001
10002
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10003 {
10004 return qe_invalid;
10005 }
10006
10007
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10008 {
10009 return qe_invalid;
10010 }
10011
10012 308 swimspr[i][spr_tile]=(int32_t)tile;
10013 308 swimspr[i][spr_flip]=(int32_t)flip;
10014 308 swimspr[i][spr_extend]=(int32_t)extend;
10015 308 }
10016 77 }
10017
10018
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10019 {
10020
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10021 {
10022 return qe_invalid;
10023 }
10024
10025
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10026 {
10027 return qe_invalid;
10028 }
10029
10030
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10031 {
10032 return qe_invalid;
10033 }
10034
10035 308 divespr[i][spr_tile]=(int32_t)tile;
10036 308 divespr[i][spr_flip]=(int32_t)flip;
10037 308 divespr[i][spr_extend]=(int32_t)extend;
10038 308 }
10039
10040
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10041 {
10042
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10043 {
10044 return qe_invalid;
10045 }
10046
10047
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10048 {
10049 return qe_invalid;
10050 }
10051
10052
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10053 {
10054 return qe_invalid;
10055 }
10056
10057 308 poundspr[i][spr_tile]=(int32_t)tile;
10058 308 poundspr[i][spr_flip]=(int32_t)flip;
10059 308 poundspr[i][spr_extend]=(int32_t)extend;
10060 308 }
10061
10062
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&tile,f))
10063 {
10064 return qe_invalid;
10065 }
10066
10067 77 flip=0;
10068
10069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>0)
10070 {
10071
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&flip,f))
10072 {
10073 return qe_invalid;
10074 }
10075 77 }
10076
10077
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&extend,f))
10078 {
10079 return qe_invalid;
10080 }
10081
10082 77 castingspr[spr_tile]=(int32_t)tile;
10083 77 castingspr[spr_flip]=(int32_t)flip;
10084 77 castingspr[spr_extend]=(int32_t)extend;
10085
10086
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(v_herosprites>0)
10087 {
10088 77 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10089
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 77 times.
231 for(int32_t i=0; i<2; i++)
10090 {
10091
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 154 times.
462 for(int32_t j=0; j<num_holdsprs; j++)
10092 {
10093
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10094 {
10095 return qe_invalid;
10096 }
10097
10098
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10099 {
10100 return qe_invalid;
10101 }
10102
10103
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10104 {
10105 return qe_invalid;
10106 }
10107
10108 308 holdspr[i][j][spr_tile]=(int32_t)tile;
10109 308 holdspr[i][j][spr_flip]=(int32_t)flip;
10110 308 holdspr[i][j][spr_extend]=(int32_t)extend;
10111 308 }
10112 154 }
10113 77 }
10114 else
10115 {
10116 for(int32_t i=0; i<2; i++)
10117 {
10118 if(!p_igetw(&tile,f))
10119 {
10120 return qe_invalid;
10121 }
10122
10123 if(!p_igetw(&tile2,f))
10124 {
10125 return qe_invalid;
10126 }
10127
10128 if(!p_getc(&extend,f))
10129 {
10130 return qe_invalid;
10131 }
10132
10133 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10134 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10135 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10136 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10137 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10138 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10139 }
10140 }
10141
10142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>2)
10143 {
10144
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10145 {
10146
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10147 {
10148 return qe_invalid;
10149 }
10150
10151
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10152 {
10153 return qe_invalid;
10154 }
10155
10156
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10157 {
10158 return qe_invalid;
10159 }
10160
10161 308 jumpspr[i][spr_tile]=(int32_t)tile;
10162 308 jumpspr[i][spr_flip]=(int32_t)flip;
10163 308 jumpspr[i][spr_extend]=(int32_t)extend;
10164 308 }
10165 77 }
10166
10167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>3)
10168 {
10169
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10170 {
10171
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10172 {
10173 return qe_invalid;
10174 }
10175
10176
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10177 {
10178 return qe_invalid;
10179 }
10180
10181
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10182 {
10183 return qe_invalid;
10184 }
10185
10186 308 chargespr[i][spr_tile]=(int32_t)tile;
10187 308 chargespr[i][spr_flip]=(int32_t)flip;
10188 308 chargespr[i][spr_extend]=(int32_t)extend;
10189 308 }
10190 77 }
10191
10192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>4)
10193 {
10194
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&dummy_byte,f))
10195 {
10196 return qe_invalid;
10197 }
10198
10199 77 zinit.hero_swim_speed=(byte)dummy_byte;
10200 77 }
10201
10202 77 memset(frozenspr, 0, sizeof(frozenspr));
10203 77 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10204 77 memset(onfirespr, 0, sizeof(onfirespr));
10205 77 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10206 77 memset(diggingspr, 0, sizeof(diggingspr));
10207 77 memset(usingrodspr, 0, sizeof(usingrodspr));
10208 77 memset(usingcanespr, 0, sizeof(usingcanespr));
10209 77 memset(pushingspr, 0, sizeof(pushingspr));
10210 77 memset(liftingspr, 0, sizeof(liftingspr));
10211 77 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10212 77 memset(stunnedspr, 0, sizeof(stunnedspr));
10213 77 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10214 77 memset(fallingspr, 0, sizeof(fallingspr));
10215 77 memset(shockedspr, 0, sizeof(shockedspr));
10216 77 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10217 77 memset(pullswordspr, 0, sizeof(pullswordspr));
10218 77 memset(readingspr, 0, sizeof(readingspr));
10219 77 memset(slash180spr, 0, sizeof(slash180spr));
10220 77 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10221 77 memset(dashspr, 0, sizeof(dashspr));
10222 77 memset(bonkspr, 0, sizeof(bonkspr));
10223 77 memset(medallionsprs, 0, sizeof(medallionsprs));
10224 77 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10225 77 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10226
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t q = 0; q < 4; ++q)
10227 {
10228
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 308 times.
1232 for(int32_t p = 0; p < 3; ++p)
10229 {
10230 924 drowningspr[q][p] = divespr[q][p];
10231 924 drowning_lavaspr[q][p] = divespr[q][p];
10232 924 }
10233 308 }
10234 77 memset(sideswimspr, 0, sizeof(sideswimspr));
10235 77 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10236 77 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10237 77 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10238 77 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10239 77 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10240 77 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10241 77 }
10242
10243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(FFCore.quest_format[vInitData] < 34)
10244 {
10245 97 bool fastswim = zinit.hero_swim_speed > 60;
10246 // '2/3' or '1/2'
10247 97 zinit.hero_swim_mult = fastswim ? 2 : 1;
10248 97 zinit.hero_swim_div = fastswim ? 3 : 2;
10249 97 }
10250 97 return 0;
10251 97 }
10252
10253 6290 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10254 {
10255 6290 arr[spr_tile] = tile;
10256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6290 times.
6290 arr[spr_flip] = (flip > 3 ? 0 : flip);
10257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6290 times.
6290 arr[spr_extend] = (ext > 2 ? 0 : ext);
10258 6290 }
10259 //Used to read the player sprites as int32_t, not word.
10260 37 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
10261 {
10262 //these are here to bypass compiler warnings about unused arguments
10263 37 cv_herosprites=cv_herosprites;
10264
10265 37 zinit.hero_swim_speed=67; //default
10266 37 setupherotiles(zinit.heroAnimationStyle);
10267 37 setupherodefenses();
10268 37 setupherooffsets();
10269
10270 int32_t tile, tile2;
10271 byte flip, extend, dummy_byte;
10272
10273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(v_herosprites>=0)
10274 {
10275
10276
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10277 {
10278
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10279 {
10280 return qe_invalid;
10281 }
10282
10283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10284 {
10285 return qe_invalid;
10286 }
10287
10288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10289 {
10290 return qe_invalid;
10291 }
10292
10293 148 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10294 148 }
10295
10296
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10297 {
10298
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10299 {
10300 return qe_invalid;
10301 }
10302
10303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10304 {
10305 return qe_invalid;
10306 }
10307
10308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10309 {
10310 return qe_invalid;
10311 }
10312
10313 148 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10314 148 }
10315
10316
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10317 {
10318
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10319 {
10320 return qe_invalid;
10321 }
10322
10323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10324 {
10325 return qe_invalid;
10326 }
10327
10328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10329 {
10330 return qe_invalid;
10331 }
10332
10333 148 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10334 148 }
10335
10336
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10337 {
10338
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10339 {
10340 return qe_invalid;
10341 }
10342
10343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10344 {
10345 return qe_invalid;
10346 }
10347
10348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10349 {
10350 return qe_invalid;
10351 }
10352
10353 148 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10354 148 }
10355
10356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(v_herosprites>1)
10357 {
10358
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10359 {
10360
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10361 {
10362 return qe_invalid;
10363 }
10364
10365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10366 {
10367 return qe_invalid;
10368 }
10369
10370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10371 {
10372 return qe_invalid;
10373 }
10374
10375 148 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10376 148 }
10377 37 }
10378
10379
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10380 {
10381
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10382 {
10383 return qe_invalid;
10384 }
10385
10386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10387 {
10388 return qe_invalid;
10389 }
10390
10391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10392 {
10393 return qe_invalid;
10394 }
10395
10396 148 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10397 148 }
10398
10399
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10400 {
10401
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10402 {
10403 return qe_invalid;
10404 }
10405
10406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10407 {
10408 return qe_invalid;
10409 }
10410
10411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10412 {
10413 return qe_invalid;
10414 }
10415
10416 148 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10417 148 }
10418
10419
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tile,f))
10420 {
10421 return qe_invalid;
10422 }
10423
10424 37 flip=0;
10425
10426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(v_herosprites>0)
10427 {
10428
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&flip,f))
10429 {
10430 return qe_invalid;
10431 }
10432 37 }
10433
10434
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&extend,f))
10435 {
10436 return qe_invalid;
10437 }
10438
10439 37 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10440
10441
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(v_herosprites>0)
10442 {
10443 37 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10444
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 37 times.
111 for(int32_t i=0; i<2; i++)
10445 {
10446
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 74 times.
296 for(int32_t j=0; j<num_holdsprs; j++)
10447 {
10448
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetl(&tile,f))
10449 {
10450 return qe_invalid;
10451 }
10452
10453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 if(!p_getc(&flip,f))
10454 {
10455 return qe_invalid;
10456 }
10457
10458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 if(!p_getc(&extend,f))
10459 {
10460 return qe_invalid;
10461 }
10462
10463 222 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10464 222 }
10465 74 }
10466 37 }
10467 else
10468 {
10469 for(int32_t i=0; i<2; i++)
10470 {
10471 if(!p_igetl(&tile,f))
10472 {
10473 return qe_invalid;
10474 }
10475
10476 if(!p_igetl(&tile2,f))
10477 {
10478 return qe_invalid;
10479 }
10480
10481 if(!p_getc(&extend,f))
10482 {
10483 return qe_invalid;
10484 }
10485
10486 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10487 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10488 }
10489 }
10490
10491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(v_herosprites>2)
10492 {
10493
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10494 {
10495
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10496 {
10497 return qe_invalid;
10498 }
10499
10500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10501 {
10502 return qe_invalid;
10503 }
10504
10505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10506 {
10507 return qe_invalid;
10508 }
10509
10510 148 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10511 148 }
10512 37 }
10513
10514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(v_herosprites>3)
10515 {
10516
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10517 {
10518
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10519 {
10520 return qe_invalid;
10521 }
10522
10523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10524 {
10525 return qe_invalid;
10526 }
10527
10528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10529 {
10530 return qe_invalid;
10531 }
10532
10533 148 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10534 148 }
10535 37 }
10536
10537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(v_herosprites>4)
10538 {
10539
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&dummy_byte,f))
10540 {
10541 return qe_invalid;
10542 }
10543
10544 37 zinit.hero_swim_speed=(byte)dummy_byte;
10545 37 }
10546
10547
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(v_herosprites>6)
10548 {
10549
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10550 {
10551
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10552 return qe_invalid;
10553
10554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10555 return qe_invalid;
10556
10557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10558 return qe_invalid;
10559
10560 148 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10561 148 }
10562
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10563 {
10564
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10565 return qe_invalid;
10566
10567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10568 return qe_invalid;
10569
10570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10571 return qe_invalid;
10572
10573 148 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10574 148 }
10575
10576
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10577 {
10578
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10579 return qe_invalid;
10580
10581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10582 return qe_invalid;
10583
10584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10585 return qe_invalid;
10586
10587 148 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10588 148 }
10589
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10590 {
10591
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10592 return qe_invalid;
10593
10594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10595 return qe_invalid;
10596
10597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10598 return qe_invalid;
10599
10600 148 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10601 148 }
10602
10603
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10604 {
10605
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10606 return qe_invalid;
10607
10608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10609 return qe_invalid;
10610
10611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10612 return qe_invalid;
10613
10614 148 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10615 148 }
10616
10617
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10618 {
10619
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10620 return qe_invalid;
10621
10622
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10623 return qe_invalid;
10624
10625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10626 return qe_invalid;
10627
10628 148 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10629 148 }
10630
10631
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10632 {
10633
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10634 return qe_invalid;
10635
10636
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10637 return qe_invalid;
10638
10639
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10640 return qe_invalid;
10641
10642 148 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10643 148 }
10644
10645
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10646 {
10647
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10648 return qe_invalid;
10649
10650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10651 return qe_invalid;
10652
10653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10654 return qe_invalid;
10655
10656 148 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10657 148 }
10658
10659
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10660 {
10661
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10662 return qe_invalid;
10663
10664
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10665 return qe_invalid;
10666
10667
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10668 return qe_invalid;
10669
10670 148 byte frames = 0;
10671
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 140 times.
148 if(v_herosprites > 15)
10672 {
10673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&frames,f))
10674 return qe_invalid;
10675 140 }
10676
10677 148 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10678 148 liftingspr[q][spr_frames] = frames;
10679 148 }
10680
10681
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10682 {
10683
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10684 return qe_invalid;
10685
10686
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10687 return qe_invalid;
10688
10689
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10690 return qe_invalid;
10691
10692 148 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10693 148 }
10694
10695
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10696 {
10697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_igetl(&tile,f))
10698 return qe_invalid;
10699
10700
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10701 return qe_invalid;
10702
10703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10704 return qe_invalid;
10705
10706 148 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10707 148 }
10708
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10709 {
10710
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10711 return qe_invalid;
10712
10713
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10714 return qe_invalid;
10715
10716
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10717 return qe_invalid;
10718
10719 148 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10720 148 }
10721
10722
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10723 {
10724
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10725 return qe_invalid;
10726
10727
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10728 return qe_invalid;
10729
10730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10731 return qe_invalid;
10732
10733 148 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10734 148 }
10735
10736
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10737 {
10738
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10739 return qe_invalid;
10740
10741
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10742 return qe_invalid;
10743
10744
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10745 return qe_invalid;
10746
10747 148 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10748 148 }
10749
10750
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10751 {
10752
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10753 return qe_invalid;
10754
10755
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10756 return qe_invalid;
10757
10758
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10759 return qe_invalid;
10760
10761 148 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10762 148 }
10763
10764
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10765 {
10766
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10767 return qe_invalid;
10768
10769
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10770 return qe_invalid;
10771
10772
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10773 return qe_invalid;
10774
10775 148 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10776 148 }
10777
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10778 {
10779
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10780 return qe_invalid;
10781
10782
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10783 return qe_invalid;
10784
10785
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10786 return qe_invalid;
10787
10788 148 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10789 148 }
10790
10791
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10792 {
10793
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10794 return qe_invalid;
10795
10796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10797 return qe_invalid;
10798
10799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10800 return qe_invalid;
10801
10802 148 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10803 148 }
10804
10805
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10806 {
10807
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10808 return qe_invalid;
10809
10810
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10811 return qe_invalid;
10812
10813
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10814 return qe_invalid;
10815
10816 148 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10817 148 }
10818
10819
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10820 {
10821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_igetl(&tile,f))
10822 return qe_invalid;
10823
10824
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10825 return qe_invalid;
10826
10827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10828 return qe_invalid;
10829
10830 148 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10831 148 }
10832
10833
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10834 {
10835
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10836 return qe_invalid;
10837
10838
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10839 return qe_invalid;
10840
10841
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10842 return qe_invalid;
10843
10844 148 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10845 148 }
10846
10847
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10848 {
10849
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10850 return qe_invalid;
10851
10852
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10853 return qe_invalid;
10854
10855
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10856 return qe_invalid;
10857
10858 148 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10859 148 }
10860
10861
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10862 {
10863
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10864 return qe_invalid;
10865
10866
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10867 return qe_invalid;
10868
10869
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10870 return qe_invalid;
10871
10872 148 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10873 148 }
10874
10875
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 37 times.
148 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10876 {
10877
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetl(&tile,f))
10878 return qe_invalid;
10879
10880
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_getc(&flip,f))
10881 return qe_invalid;
10882
10883
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_getc(&extend,f))
10884 return qe_invalid;
10885
10886 111 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10887 111 }
10888 37 }
10889 else
10890 {
10891 memset(frozenspr, 0, sizeof(frozenspr));
10892 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10893 memset(onfirespr, 0, sizeof(onfirespr));
10894 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10895 memset(diggingspr, 0, sizeof(diggingspr));
10896 memset(usingrodspr, 0, sizeof(usingrodspr));
10897 memset(usingcanespr, 0, sizeof(usingcanespr));
10898 memset(pushingspr, 0, sizeof(pushingspr));
10899 memset(liftingspr, 0, sizeof(liftingspr));
10900 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10901 memset(stunnedspr, 0, sizeof(stunnedspr));
10902 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10903 memset(fallingspr, 0, sizeof(fallingspr));
10904 memset(shockedspr, 0, sizeof(shockedspr));
10905 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10906 memset(pullswordspr, 0, sizeof(pullswordspr));
10907 memset(readingspr, 0, sizeof(readingspr));
10908 memset(slash180spr, 0, sizeof(slash180spr));
10909 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10910 memset(dashspr, 0, sizeof(dashspr));
10911 memset(bonkspr, 0, sizeof(bonkspr));
10912 memset(medallionsprs, 0, sizeof(medallionsprs));
10913 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10914 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10915 for(int32_t q = 0; q < 4; ++q)
10916 {
10917 for(int32_t p = 0; p < 3; ++p)
10918 {
10919 drowningspr[q][p] = divespr[q][p];
10920 drowning_lavaspr[q][p] = divespr[q][p];
10921 }
10922 }
10923 }
10924
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if (v_herosprites > 8)
10925 {
10926
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10927 {
10928
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10929 return qe_invalid;
10930
10931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10932 return qe_invalid;
10933
10934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10935 return qe_invalid;
10936
10937 148 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10938 148 }
10939 37 }
10940 else
10941 {
10942 memset(sideswimspr, 0, sizeof(sideswimspr));
10943 }
10944
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if (v_herosprites > 9)
10945 {
10946
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10947 {
10948
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10949 return qe_invalid;
10950
10951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10952 return qe_invalid;
10953
10954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10955 return qe_invalid;
10956
10957 148 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10958 148 }
10959
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10960 {
10961
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10962 return qe_invalid;
10963
10964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10965 return qe_invalid;
10966
10967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10968 return qe_invalid;
10969
10970 148 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10971 148 }
10972
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10973 {
10974
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10975 return qe_invalid;
10976
10977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10978 return qe_invalid;
10979
10980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10981 return qe_invalid;
10982
10983 148 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10984 148 }
10985
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10986 {
10987
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10988 return qe_invalid;
10989
10990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10991 return qe_invalid;
10992
10993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10994 return qe_invalid;
10995
10996 148 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10997 148 }
10998 37 }
10999 else
11000 {
11001 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11002 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11003 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11004 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11005 }
11006
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if (v_herosprites > 10)
11007 {
11008
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
11009 {
11010 int32_t hmr;
11011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_igetl(&hmr,f))
11012 return qe_invalid;
11013
11014 148 hammeroffsets[q] = hmr;
11015 148 }
11016 37 }
11017 else
11018 {
11019 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11020 }
11021
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if (v_herosprites > 11)
11022 {
11023
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 37 times.
148 for(int32_t q = 0; q < 3; ++q)
11024 {
11025
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetl(&tile,f))
11026 return qe_invalid;
11027
11028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(!p_getc(&flip,f))
11029 return qe_invalid;
11030
11031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(!p_getc(&extend,f))
11032 return qe_invalid;
11033
11034 111 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11035 111 }
11036 37 }
11037 else
11038 {
11039 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11040 }
11041
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if (v_herosprites > 12)
11042 {
11043
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tile,f))
11044 return qe_invalid;
11045
11046
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&flip,f))
11047 return qe_invalid;
11048
11049
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&extend,f))
11050 return qe_invalid;
11051 37 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11052
11053 37 }
11054 else
11055 {
11056 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11057 }
11058
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if (v_herosprites > 13)
11059 {
11060
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
11061 {
11062
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
11063 return qe_invalid;
11064
11065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
11066 return qe_invalid;
11067
11068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
11069 return qe_invalid;
11070
11071 148 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11072 148 }
11073 37 }
11074 else
11075 {
11076 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11077 }
11078
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if (v_herosprites > 14)
11079 {
11080
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
11081 {
11082
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
11083 return qe_invalid;
11084
11085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
11086 return qe_invalid;
11087
11088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
11089 return qe_invalid;
11090
11091 148 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11092 148 }
11093 37 }
11094 else
11095 {
11096 memset(revslashspr, 0, sizeof(revslashspr));
11097 }
11098
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if (v_herosprites > 7)
11099 {
11100 37 int32_t num_defense = wMax;
11101 37 byte def = 0;
11102
11103 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11104 /*if(v_herosprites > [x])
11105 * {
11106 * num_defense = 146 //value of wMax on version 8
11107 * }
11108 */
11109
11110
2/2
✓ Branch 0 taken 5402 times.
✓ Branch 1 taken 37 times.
5439 for (int32_t q = 0; q < num_defense; q++)
11111 {
11112
1/2
✓ Branch 0 taken 5402 times.
✗ Branch 1 not taken.
5402 if (!p_getc(&def, f))
11113 return qe_invalid;
11114
11115 5402 hero_defence[q] = def;
11116 5402 }
11117 37 }
11118 else
11119 {
11120 int32_t num_defense = wMax;
11121 for (int32_t q = 0; q < num_defense; q++)
11122 {
11123 hero_defence[q] = 0;
11124 }
11125 }
11126 37 }
11127
11128
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 5 times.
37 if(FFCore.quest_format[vInitData] < 34)
11129 {
11130 5 bool fastswim = zinit.hero_swim_speed > 60;
11131 // '2/3' or '1/2'
11132 5 zinit.hero_swim_mult = fastswim ? 2 : 1;
11133 5 zinit.hero_swim_div = fastswim ? 3 : 2;
11134 5 }
11135 37 return 0;
11136 37 }
11137
11138
11139 114 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11140 {
11141 //these are here to bypass compiler warnings about unused arguments
11142 114 Header=Header;
11143
11144 dword dummy;
11145 114 word s_version=0, s_cversion=0;
11146
11147 //section version info
11148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_igetw(&s_version,f))
11149 {
11150 return qe_invalid;
11151 }
11152
11153 114 FFCore.quest_format[vHeroSprites] = s_version;
11154
11155 //al_trace("Player sprites version %d\n", s_version);
11156
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&s_cversion,f))
11157 {
11158 return qe_invalid;
11159 }
11160
11161 //section size
11162
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&dummy,f))
11163 {
11164 return qe_invalid;
11165 }
11166
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 77 times.
114 if ( s_version >= 6 )
11167 {
11168 //al_trace("Reading Player Sprites v6\n");
11169 37 return readherosprites3(f, s_version, dummy);
11170 }
11171 77 else return readherosprites2(f, s_version, dummy);
11172 114 }
11173
11174 86 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11175 {
11176 86 subscreens_active.clear();
11177 86 subscreens_passive.clear();
11178 86 subscreens_overlay.clear();
11179
2/2
✓ Branch 0 taken 11008 times.
✓ Branch 1 taken 86 times.
11094 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11180 {
11181 subscreen_group g;
11182 11008 memset(&g,0,sizeof(subscreen_group));
11183 11008 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11008 times.
11008 if(ret!=0)
11185 return ret;
11186
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 10613 times.
11008 if(g.objects[0].type == ssoNULL) continue;
11187
2/2
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 207 times.
395 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11188 395 ZCSubscreen& sub = vec.emplace_back();
11189 395 sub.load_old(g);
11190 395 }
11191
11192 86 return 0;
11193 86 }
11194
11195 11008 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11196 {
11197 11008 int32_t numsub=0;
11198 11008 byte temp_ss=0;
11199 subscreen_object temp_sub_stack;
11200 11008 subscreen_object *temp_sub = &temp_sub_stack;
11201
11202 char tempname[64];
11203
11204 // FWIW I never saw anything bigger than 20.
11205 #define MAX_DP1_LEN 1024
11206 char tempdp1[MAX_DP1_LEN];
11207
11208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11008 times.
11008 if(!pfread(tempname,64,f))
11209 {
11210 return qe_invalid;
11211 }
11212
11213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11008 times.
11008 if(s_version > 1)
11214 {
11215
1/2
✓ Branch 0 taken 11008 times.
✗ Branch 1 not taken.
11008 if(!p_getc(&temp_ss,f))
11216 {
11217 return qe_invalid;
11218 }
11219 11008 }
11220
11221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11008 times.
11008 if(s_version < 4)
11222 {
11223 uint8_t tmp=0;
11224
11225 if(!p_getc(&tmp,f))
11226 {
11227 return qe_invalid;
11228 }
11229
11230 numsub = (int32_t)tmp;
11231 }
11232 else
11233 {
11234 word tmp;
11235
11236
1/2
✓ Branch 0 taken 11008 times.
✗ Branch 1 not taken.
11008 if(!p_igetw(&tmp, f))
11237 {
11238 return qe_invalid;
11239 }
11240
11241 11008 numsub = (int32_t)tmp;
11242 }
11243
11244 int32_t j;
11245
11246
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24251 times.
✓ Branch 2 taken 13243 times.
✓ Branch 3 taken 11008 times.
24251 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11247 {
11248 13243 memset(temp_sub,0,sizeof(subscreen_object));
11249
11250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13243 times.
13243 switch(g->objects[j].type)
11251 {
11252 case ssoTEXT:
11253 case ssoTEXTBOX:
11254 case ssoCURRENTITEMTEXT:
11255 case ssoCURRENTITEMCLASSTEXT:
11256 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11257
11258 //fall through
11259 default:
11260 13243 memset(&g->objects[j],0,sizeof(subscreen_object));
11261 13243 break;
11262 }
11263
11264
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->type),f))
11265 return qe_invalid;
11266
11267
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->pos),f))
11268 return qe_invalid;
11269
11270
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(s_version < 5)
11271 {
11272 switch(temp_sub->pos)
11273 {
11274 case 0:
11275 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11276 break;
11277
11278 case 1:
11279 temp_sub->pos = sspUP;
11280 break;
11281
11282 case 2:
11283 temp_sub->pos = sspDOWN;
11284 break;
11285
11286 default:
11287 temp_sub->pos = 0;
11288 }
11289 }
11290
11291
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->x),f))
11292 return qe_invalid;
11293
11294
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->y),f))
11295 return qe_invalid;
11296
11297
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->w),f))
11298 return qe_invalid;
11299
11300
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->h),f))
11301 return qe_invalid;
11302
11303
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->colortype1),f))
11304 return qe_invalid;
11305
11306
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->color1),f))
11307 return qe_invalid;
11308
11309
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->colortype2),f))
11310 return qe_invalid;
11311
11312
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->color2),f))
11313 return qe_invalid;
11314
11315
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->colortype3),f))
11316 return qe_invalid;
11317
11318
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->color3),f))
11319 return qe_invalid;
11320
11321
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d1),f))
11322 return qe_invalid;
11323
11324
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d2),f))
11325 return qe_invalid;
11326
11327
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d3),f))
11328 return qe_invalid;
11329
11330
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d4),f))
11331 return qe_invalid;
11332
11333
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d5),f))
11334 return qe_invalid;
11335
11336
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d6),f))
11337 return qe_invalid;
11338
11339
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d7),f))
11340 return qe_invalid;
11341
11342
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d8),f))
11343 return qe_invalid;
11344
11345
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d9),f))
11346 return qe_invalid;
11347
11348
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d10),f))
11349 return qe_invalid;
11350
11351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13243 times.
13243 if(s_version < 2)
11352 {
11353 if(!p_igetl(&(temp_sub->speed),f))
11354 return qe_invalid;
11355
11356 if(!p_igetl(&(temp_sub->delay),f))
11357 return qe_invalid;
11358
11359 if(!p_igetl(&(temp_sub->frame),f))
11360 return qe_invalid;
11361 }
11362 else
11363 {
11364
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->speed),f))
11365 return qe_invalid;
11366
11367
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->delay),f))
11368 return qe_invalid;
11369
11370
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->frame),f))
11371 return qe_invalid;
11372 }
11373
11374 13243 int32_t temp_size=0;
11375
11376 // bool deletets = false;
11377
4/4
✓ Branch 0 taken 5853 times.
✓ Branch 1 taken 1329 times.
✓ Branch 2 taken 5910 times.
✓ Branch 3 taken 151 times.
13243 switch(temp_sub->type)
11378 {
11379 case ssoTEXT:
11380 case ssoTEXTBOX:
11381 case ssoCURRENTITEMTEXT:
11382 case ssoCURRENTITEMCLASSTEXT:
11383 {
11384 word temptempsize;
11385
11386
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if(!p_igetw(&temptempsize,f))
11387 {
11388 return qe_invalid;
11389 }
11390
11391 //temptempsize = temp1 + (temp2 << 8);
11392 1329 temp_size = (int32_t)temptempsize;
11393 1329 uint32_t char_length = temp_size+2;
11394
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if (char_length > MAX_DP1_LEN)
11395 {
11396 return qe_invalid;
11397 }
11398 1329 tempdp1[char_length - 1] = '\0';
11399
11400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1329 times.
1329 if(temp_size)
11401
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if(!pfread(tempdp1,temp_size+1,f))
11402 return qe_invalid;
11403 1329 break;
11404 }
11405
11406 case ssoLIFEMETER:
11407
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11408 temp_sub->d3 = 1;
11409
11410
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&(temp_sub->dp1),f))
11411 return qe_invalid;
11412
11413 151 break;
11414
11415
11416 case ssoCURRENTITEM:
11417
11418
1/2
✓ Branch 0 taken 5853 times.
✗ Branch 1 not taken.
5853 if(s_version < 6)
11419 {
11420 switch(temp_sub->d1)
11421 {
11422 case ssiBOMB:
11423 temp_sub->d1 = itype_bomb;
11424 break;
11425
11426 case ssiSWORD:
11427 temp_sub->d1 = itype_sword;
11428 break;
11429
11430 case ssiSHIELD:
11431 temp_sub->d1 = itype_shield;
11432 break;
11433
11434 case ssiCANDLE:
11435 temp_sub->d1 = itype_candle;
11436 break;
11437
11438 case ssiLETTER:
11439 temp_sub->d1 = itype_letter;
11440 break;
11441
11442 case ssiPOTION:
11443 temp_sub->d1 = itype_potion;
11444 break;
11445
11446 case ssiLETTERPOTION:
11447 temp_sub->d1 = itype_letterpotion;
11448 break;
11449
11450 case ssiBOW:
11451 temp_sub->d1 = itype_bow;
11452 break;
11453
11454 case ssiARROW:
11455 temp_sub->d1 = itype_arrow;
11456 break;
11457
11458 case ssiBOWANDARROW:
11459 temp_sub->d1 = itype_bowandarrow;
11460 break;
11461
11462 case ssiBAIT:
11463 temp_sub->d1 = itype_bait;
11464 break;
11465
11466 case ssiRING:
11467 temp_sub->d1 = itype_ring;
11468 break;
11469
11470 case ssiBRACELET:
11471 temp_sub->d1 = itype_bracelet;
11472 break;
11473
11474 case ssiMAP:
11475 temp_sub->d1 = itype_map;
11476 break;
11477
11478 case ssiCOMPASS:
11479 temp_sub->d1 = itype_compass;
11480 break;
11481
11482 case ssiBOSSKEY:
11483 temp_sub->d1 = itype_bosskey;
11484 break;
11485
11486 case ssiMAGICKEY:
11487 temp_sub->d1 = itype_magickey;
11488 break;
11489
11490 case ssiBRANG:
11491 temp_sub->d1 = itype_brang;
11492 break;
11493
11494 case ssiWAND:
11495 temp_sub->d1 = itype_wand;
11496 break;
11497
11498 case ssiRAFT:
11499 temp_sub->d1 = itype_raft;
11500 break;
11501
11502 case ssiLADDER:
11503 temp_sub->d1 = itype_ladder;
11504 break;
11505
11506 case ssiWHISTLE:
11507 temp_sub->d1 = itype_whistle;
11508 break;
11509
11510 case ssiBOOK:
11511 temp_sub->d1 = itype_book;
11512 break;
11513
11514 case ssiWALLET:
11515 temp_sub->d1 = itype_wallet;
11516 break;
11517
11518 case ssiSBOMB:
11519 temp_sub->d1 = itype_sbomb;
11520 break;
11521
11522 case ssiHCPIECE:
11523 temp_sub->d1 = itype_heartpiece;
11524 break;
11525
11526 case ssiAMULET:
11527 temp_sub->d1 = itype_amulet;
11528 break;
11529
11530 case ssiFLIPPERS:
11531 temp_sub->d1 = itype_flippers;
11532 break;
11533
11534 case ssiHOOKSHOT:
11535 temp_sub->d1 = itype_hookshot;
11536 break;
11537
11538 case ssiLENS:
11539 temp_sub->d1 = itype_lens;
11540 break;
11541
11542 case ssiHAMMER:
11543 temp_sub->d1 = itype_hammer;
11544 break;
11545
11546 case ssiBOOTS:
11547 temp_sub->d1 = itype_boots;
11548 break;
11549
11550 case ssiDIVINEFIRE:
11551 temp_sub->d1 = itype_divinefire;
11552 break;
11553
11554 case ssiDIVINEESCAPE:
11555 temp_sub->d1 = itype_divineescape;
11556 break;
11557
11558 case ssiDIVINEPROTECTION:
11559 temp_sub->d1 = itype_divineprotection;
11560 break;
11561
11562 case ssiQUIVER:
11563 temp_sub->d1 = itype_quiver;
11564 break;
11565
11566 case ssiBOMBBAG:
11567 temp_sub->d1 = itype_bombbag;
11568 break;
11569
11570 case ssiCBYRNA:
11571 temp_sub->d1 = itype_cbyrna;
11572 break;
11573
11574 case ssiROCS:
11575 temp_sub->d1 = itype_rocs;
11576 break;
11577
11578 case ssiHOVERBOOTS:
11579 temp_sub->d1 = itype_hoverboots;
11580 break;
11581
11582 case ssiSPINSCROLL:
11583 temp_sub->d1 = itype_spinscroll;
11584 break;
11585
11586 case ssiCROSSSCROLL:
11587 temp_sub->d1 = itype_crossscroll;
11588 break;
11589
11590 case ssiQUAKESCROLL:
11591 temp_sub->d1 = itype_quakescroll;
11592 break;
11593
11594 case ssiWHISPRING:
11595 temp_sub->d1 = itype_whispring;
11596 break;
11597
11598 case ssiCHARGERING:
11599 temp_sub->d1 = itype_chargering;
11600 break;
11601
11602 case ssiPERILSCROLL:
11603 temp_sub->d1 = itype_perilscroll;
11604 break;
11605
11606 case ssiWEALTHMEDAL:
11607 temp_sub->d1 = itype_wealthmedal;
11608 break;
11609
11610 case ssiHEARTRING:
11611 temp_sub->d1 = itype_heartring;
11612 break;
11613
11614 case ssiMAGICRING:
11615 temp_sub->d1 = itype_magicring;
11616 break;
11617
11618 case ssiSPINSCROLL2:
11619 temp_sub->d1 = itype_spinscroll2;
11620 break;
11621
11622 case ssiQUAKESCROLL2:
11623 temp_sub->d1 = itype_quakescroll2;
11624 break;
11625
11626 case ssiAGONY:
11627 temp_sub->d1 = itype_agony;
11628 break;
11629
11630 case ssiSTOMPBOOTS:
11631 temp_sub->d1 = itype_stompboots;
11632 break;
11633
11634 case ssiWHIMSICALRING:
11635 temp_sub->d1 = itype_whimsicalring;
11636 break;
11637
11638 case ssiPERILRING:
11639 temp_sub->d1 = itype_perilring;
11640 break;
11641
11642 default:
11643 temp_sub->d1 += itype_custom1 - ssiMAX;
11644 }
11645 }
11646
11647 //fall-through
11648 default:
11649
1/2
✓ Branch 0 taken 11763 times.
✗ Branch 1 not taken.
11763 if(!p_getc(&(temp_sub->dp1),f))
11650 return qe_invalid;
11651
11652 11763 break;
11653 }
11654
11655
2/2
✓ Branch 0 taken 4559 times.
✓ Branch 1 taken 8684 times.
13243 if(s_version < 7)
11656 {
11657
3/3
✓ Branch 0 taken 8025 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 432 times.
8684 switch(temp_sub->type)
11658 {
11659 case ssoMAGICGAUGE:
11660 {
11661
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(!temp_sub->d9)
11662 192 temp_sub->d9 = -1; //-1 now represents 'always'
11663 227 break;
11664 }
11665 case ssoLIFEGAUGE:
11666 432 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11667 432 break;
11668 }
11669 8684 }
11670
11671
3/3
✓ Branch 0 taken 1329 times.
✓ Branch 1 taken 11457 times.
✓ Branch 2 taken 457 times.
13243 switch(temp_sub->type)
11672 {
11673 case ssoTEXT:
11674 case ssoTEXTBOX:
11675 case ssoCURRENTITEMTEXT:
11676 case ssoCURRENTITEMCLASSTEXT:
11677
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1329 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1329 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11678
11679 1329 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11680 1329 g->objects[j].dp1 = new char[temp_size+2];
11681 1329 strcpy((char*)g->objects[j].dp1,tempdp1);
11682 1329 break;
11683
11684 case ssoCOUNTER:
11685
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(s_version<3)
11686 {
11687 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11688 temp_sub->d8=0;
11689 }
11690
11691 default:
11692 11914 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11693 11914 break;
11694 }
11695
11696 13243 g->name[0] = '\0';
11697 13243 strncat(g->name, tempname, 64 - 1);
11698 13243 g->ss_type = temp_ss;
11699 13243 }
11700
11701
2/2
✓ Branch 0 taken 2804805 times.
✓ Branch 1 taken 11008 times.
2815813 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11702 {
11703 //clear all unused object in this subscreen -DD
11704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2804805 times.
2804805 switch(g->objects[j].type)
11705 {
11706 case ssoTEXT:
11707 case ssoTEXTBOX:
11708 case ssoCURRENTITEMTEXT:
11709 case ssoCURRENTITEMCLASSTEXT:
11710 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11711
11712 //fall through
11713 default:
11714 2804805 memset(&g->objects[j],0,sizeof(subscreen_object));
11715 2804805 break;
11716 }
11717 2804805 }
11718
11719 11008 return 0;
11720 11008 }
11721
11722 114 int32_t readsubscreens(PACKFILE *f)
11723 {
11724 word s_version, s_cversion;
11725 dword dummy;
11726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_igetw(&s_version,f))
11727 return qe_invalid;
11728 114 FFCore.quest_format[vSubscreen] = s_version;
11729
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&s_cversion,f))
11730 return qe_invalid;
11731
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&dummy,f)) //section size
11732 return qe_invalid;
11733
11734
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 28 times.
114 if(s_version < 8)
11735 86 return read_old_subscreens(f,s_version);
11736
11737 28 subscreens_active.clear();
11738 28 subscreens_passive.clear();
11739 28 subscreens_overlay.clear();
11740
11741 byte sz;
11742
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&sz,f))
11743 return qe_invalid;
11744
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 28 times.
116 for(byte q = 0; q < sz; ++q)
11745 {
11746 88 ZCSubscreen& tmp = subscreens_active.emplace_back();
11747
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if (auto ret = tmp.read(f, s_version))
11748 return ret;
11749 88 }
11750
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&sz,f))
11751 return qe_invalid;
11752
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 28 times.
140 for(byte q = 0; q < sz; ++q)
11753 {
11754 112 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11755
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if (auto ret = tmp.read(f, s_version))
11756 return ret;
11757 112 }
11758
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&sz,f))
11759 return qe_invalid;
11760
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 28 times.
44 for(byte q = 0; q < sz; ++q)
11761 {
11762 16 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (auto ret = tmp.read(f, s_version))
11764 return ret;
11765 16 }
11766 28 return 0;
11767 114 }
11768
11769 void reset_subscreen(subscreen_group *tempss)
11770 {
11771 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11772 {
11773 switch(tempss->objects[i].type)
11774 {
11775 case ssoTEXT:
11776 case ssoTEXTBOX:
11777 case ssoCURRENTITEMTEXT:
11778 case ssoCURRENTITEMCLASSTEXT:
11779 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11780
11781 //fall through
11782 default:
11783 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11784 break;
11785 }
11786 }
11787 }
11788
11789 31 void reset_subscreens()
11790 {
11791 31 subscreens_active.clear();
11792 31 subscreens_passive.clear();
11793 31 subscreens_overlay.clear();
11794 31 }
11795
11796 31 int32_t setupsubscreens()
11797 {
11798 31 reset_subscreens();
11799 //return 0;
11800
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 62 times.
93 for(int q = 0; q < 2; ++q)
11801 {
11802 62 subscreens_active.emplace_back();
11803 62 subscreens_passive.emplace_back();
11804 62 }
11805 31 int32_t tempsubscreen=zinit.subscreen;
11806
11807
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(tempsubscreen>=ssdtMAX)
11808 tempsubscreen=0;
11809
11810
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 switch(tempsubscreen)
11811 {
11812 case ssdtOLD:
11813 case ssdtNEWSUBSCR:
11814 case ssdtREV2:
11815 case ssdtBSZELDA:
11816 case ssdtBSZELDAMODIFIED:
11817 case ssdtBSZELDAENHANCED:
11818 case ssdtBSZELDACOMPLETE:
11819 {
11820 31 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
11821 31 subscreens_active[0].sub_type=sstACTIVE;
11822 31 subscreens_active[0].name = "Active Subscreen (Triforce)";
11823 31 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
11824 31 subscreens_active[1].sub_type=sstACTIVE;
11825 31 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
11826 31 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
11827 31 subscreens_passive[0].sub_type=sstPASSIVE;
11828 31 subscreens_passive[0].name = "Passive Subscreen (Magic)";
11829 31 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
11830 31 subscreens_passive[1].sub_type=sstPASSIVE;
11831 31 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
11832 31 break;
11833 }
11834
11835 case ssdtZ3:
11836 {
11837 subscreens_active[0].load_old(z3_active_a);
11838 subscreens_active[0].sub_type=sstACTIVE;
11839 subscreens_active[1].load_old(z3_active_ab);
11840 subscreens_active[1].sub_type=sstACTIVE;
11841 subscreens_passive[0].load_old(z3_passive_a);
11842 subscreens_passive[0].sub_type=sstPASSIVE;
11843 subscreens_passive[1].load_old(z3_passive_ab);
11844 subscreens_passive[1].sub_type=sstPASSIVE;
11845 break;
11846 }
11847 }
11848
11849 31 return 0;
11850 }
11851
11852 extern script_data *ffscripts[NUMSCRIPTFFC];
11853 extern script_data *itemscripts[NUMSCRIPTITEM];
11854 extern script_data *guyscripts[NUMSCRIPTGUYS];
11855 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
11856 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
11857 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
11858 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
11859 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
11860 extern script_data *playerscripts[NUMSCRIPTPLAYER];
11861 extern script_data *screenscripts[NUMSCRIPTSCREEN];
11862 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
11863 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
11864 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
11865 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
11866 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
11867
11868
11869
11870 104 int32_t readffscript(PACKFILE *f, zquestheader *Header)
11871 {
11872 int32_t dummy;
11873 104 word s_version=0, s_cversion=0, zmeta_version=0;
11874 104 byte numscripts=0;
11875 104 numscripts=numscripts; //to avoid unused variables warnings
11876 int32_t ret;
11877
11878 //section version info
11879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_igetw(&s_version,f))
11880 {
11881 return qe_invalid;
11882 }
11883
11884 104 FFCore.quest_format[vFFScript] = s_version;
11885
11886
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_cversion,f))
11887 {
11888 return qe_invalid;
11889 }
11890
11891
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 37 times.
104 if(s_version >= 18)
11892 {
11893
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetw(&zmeta_version,f))
11894 {
11895 return qe_invalid;
11896 }
11897 37 }
11898
11899 //al_trace("Scripts version %d\n", s_version);
11900 //section size
11901
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f))
11902 {
11903 return qe_invalid;
11904 }
11905
11906 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
11907 104 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
11908 104 temp_ffscript_version = s_version;
11909 //miscQdata *the_misc;
11910
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 77 times.
104 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
11911 104 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
11912
11913 //finally... section data
11914
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 60 times.
58472 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
11915 {
11916 58368 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
11917
11918
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if (ret)
11919 {
11920 return qe_invalid;
11921 }
11922 58368 }
11923
11924 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
11925 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
11926 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
11927 * there was a version bump a week before a change that broke stuff.
11928 */
11929
7/8
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 37 times.
✓ Branch 7 taken 37 times.
60 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
11930 {
11931 97 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
11932 97 }
11933
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 77 times.
114 if(s_version < 19)
11934 {
11935 77 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
11936 77 }
11937
11938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(s_version > 1)
11939 {
11940
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
11941 {
11942 29184 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
11943
11944
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if (ret)
11945 {
11946 return qe_invalid;
11947 }
11948 29184 }
11949
11950
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
11951 {
11952 29184 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
11953
11954
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if (ret)
11955 {
11956 return qe_invalid;
11957 }
11958 29184 }
11959
11960
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
11961 {
11962 29184 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
11963
11964
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if (ret)
11965 {
11966 return qe_invalid;
11967 }
11968 29184 }
11969
11970
11971
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
11972 {
11973 29184 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
11974
11975
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if (ret)
11976 {
11977 return qe_invalid;
11978 }
11979 29184 }
11980
11981
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 77 times.
114 if(s_version > 16)
11982 {
11983
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 37 times.
333 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
11984 {
11985 296 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
11986
11987
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if (ret)
11988 {
11989 return qe_invalid;
11990 }
11991 296 }
11992 37 }
11993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 else if(s_version > 13)
11994 {
11995 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
11996 {
11997 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
11998
11999 if (ret)
12000 {
12001 return qe_invalid;
12002 }
12003 }
12004
12005 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12006 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12007
12008 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12009 }
12010
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 else if(s_version > 4)
12011 {
12012
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12013 {
12014 308 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12015
12016
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if (ret)
12017 {
12018 return qe_invalid;
12019 }
12020 308 }
12021
12022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12023
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12024
12025
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12026
12027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12028
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12029
12030
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12031
12032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12033
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_F6];
12034
12035
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12036
12037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12038
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12039
12040
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12041 77 }
12042 else
12043 {
12044 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12045 {
12046 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12047
12048 if (ret)
12049 {
12050 return qe_invalid;
12051 }
12052 }
12053
12054 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12055 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12056
12057 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12058
12059 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12060 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12061
12062 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12063
12064 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12065 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12066
12067 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12068
12069 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12070 delete globalscripts[GLOBAL_SCRIPT_F6];
12071
12072 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12073
12074 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12075 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12076
12077 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12078 }
12079
12080
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 77 times.
114 if(s_version > 10) //expanded the number of Player scripts to 5.
12081 {
12082
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 37 times.
222 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12083 {
12084 185 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12085
12086
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if (ret)
12087 {
12088 return qe_invalid;
12089 }
12090 185 }
12091 37 }
12092 else
12093 {
12094
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 77 times.
308 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12095 {
12096 231 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12097
12098
1/2
✓ Branch 0 taken 231 times.
✗ Branch 1 not taken.
231 if (ret)
12099 {
12100 return qe_invalid;
12101 }
12102 231 }
12103
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[3] != NULL)
12104
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete playerscripts[3];
12105
12106
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[3] = new script_data();
12107
12108
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[4] != NULL)
12109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 delete playerscripts[4];
12110
12111
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[4] = new script_data();
12112 }
12113
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
114 if(s_version > 8 && s_version < 10)
12114 {
12115
12116 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12117 {
12118 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12119
12120 if (ret)
12121 {
12122 return qe_invalid;
12123 }
12124 }
12125 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12126 {
12127 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12128
12129 if (ret)
12130 {
12131 return qe_invalid;
12132 }
12133 }
12134
12135 }
12136
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if(s_version >= 10)
12137 {
12138
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 37 times.
9509 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12139 {
12140 9472 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12141
12142
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if (ret)
12143 {
12144 return qe_invalid;
12145 }
12146 9472 }
12147
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 37 times.
9509 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12148 {
12149 9472 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12150
12151
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if (ret)
12152 {
12153 return qe_invalid;
12154 }
12155 9472 }
12156
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 37 times.
9509 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12157 {
12158 9472 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12159
12160
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if (ret)
12161 {
12162 return qe_invalid;
12163 }
12164 9472 }
12165
12166 37 }
12167
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if(s_version >=12)
12168 {
12169
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 37 times.
9509 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12170 {
12171 9472 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12172
12173
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if (ret)
12174 {
12175 return qe_invalid;
12176 }
12177 9472 }
12178 37 }
12179
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if(s_version >=15)
12180 {
12181
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 37 times.
18981 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12182 {
12183 18944 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12184
12185
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if (ret)
12186 {
12187 return qe_invalid;
12188 }
12189 18944 }
12190 37 }
12191
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if(s_version >19)
12192 {
12193 37 word numgenscripts = NUMSCRIPTSGENERIC;
12194
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetw(&numgenscripts,f))
12195 {
12196 return qe_invalid;
12197 }
12198
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 37 times.
18981 for(int32_t i = 0; i < numgenscripts; i++)
12199 {
12200 18944 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12201
12202
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if (ret)
12203 {
12204 return qe_invalid;
12205 }
12206 18944 }
12207 37 }
12208
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 8 times.
114 if(s_version >21)
12209 {
12210 8 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12211
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&numsubscripts,f))
12212 {
12213 return qe_invalid;
12214 }
12215
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i = 0; i < numsubscripts; i++)
12216 {
12217 2048 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &subscreenscripts[i], zmeta_version);
12218
12219
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 if (ret)
12220 {
12221 return qe_invalid;
12222 }
12223 2048 }
12224 8 }
12225 114 }
12226
12227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(s_version > 2)
12228 {
12229 int32_t bufsize;
12230 114 p_igetl(&bufsize, f);
12231
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if (bufsize < 0 || bufsize > 1024*1024*10)
12232 {
12233 // God help anyone storing more than 10MB of code in the script buffer.
12234 return qe_invalid;
12235 }
12236 114 char * buf = new char[bufsize+1];
12237 114 pfread(buf, bufsize, f);
12238 114 buf[bufsize]=0;
12239
12240
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 zScript = string(buf);
12241
12242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 delete[] buf;
12243 word numffcbindings;
12244 114 p_igetw(&numffcbindings, f);
12245
12246
2/2
✓ Branch 0 taken 1588 times.
✓ Branch 1 taken 114 times.
1702 for(int32_t i=0; i<numffcbindings; i++)
12247 {
12248 word id;
12249 1588 p_igetw(&id, f);
12250 1588 p_igetl(&bufsize, f);
12251
2/4
✓ Branch 0 taken 1588 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1588 times.
1588 if (bufsize < 0 || bufsize > 1024)
12252 return qe_invalid;
12253 1588 buf = new char[bufsize+1];
12254 1588 pfread(buf, bufsize, f);
12255 1588 buf[bufsize]=0;
12256
12257 //fix for buggy older saved quests -DD
12258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1588 times.
1588 if(id < NUMSCRIPTFFC-1)
12259 1588 ffcmap[id].scriptname = buf;
12260
12261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1588 times.
1588 delete[] buf;
12262 1588 }
12263
12264 word numglobalbindings;
12265 114 p_igetw(&numglobalbindings, f);
12266
12267
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 114 times.
553 for(int32_t i=0; i<numglobalbindings; i++)
12268 {
12269 word id;
12270 439 p_igetw(&id, f);
12271 439 p_igetl(&bufsize, f);
12272
2/4
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 439 times.
439 if (bufsize < 0 || bufsize > 1024)
12273 return qe_invalid;
12274 439 buf = new char[bufsize+1];
12275 439 pfread(buf, bufsize, f);
12276 439 buf[bufsize]=0;
12277
12278 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12279 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12280 // Ignore these. -DD
12281
3/4
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 280 times.
439 if(id >= 0 && id < NUMSCRIPTGLOBAL)
12282 {
12283 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12284
1/2
✓ Branch 0 taken 280 times.
✗ Branch 1 not taken.
280 if(strcmp(buf,"~Continue") == 0)
12285 {
12286 globalmap[id].scriptname = "";
12287
12288 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12289 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12290 }
12291 else
12292 {
12293 280 globalmap[id].scriptname = buf;
12294 }
12295 280 }
12296
12297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 439 times.
439 delete[] buf;
12298 439 }
12299
12300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(s_version > 3)
12301 {
12302 word numitembindings;
12303 114 p_igetw(&numitembindings, f);
12304
12305
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 114 times.
212 for(int32_t i=0; i<numitembindings; i++)
12306 {
12307 word id;
12308 98 p_igetw(&id, f);
12309 98 p_igetl(&bufsize, f);
12310
2/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
98 if (bufsize < 0 || bufsize > 1024)
12311 return qe_invalid;
12312 98 buf = new char[bufsize+1];
12313 98 pfread(buf, bufsize, f);
12314 98 buf[bufsize]=0;
12315
12316 //fix this too
12317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if(id <NUMSCRIPTITEM-1)
12318 98 itemmap[id].scriptname = buf;
12319
12320
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 delete[] buf;
12321 98 }
12322 114 }
12323 //(v9+)
12324
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if(s_version > 8)
12325 {
12326 //npc scripts
12327 word numnpcbindings;
12328 37 p_igetw(&numnpcbindings, f);
12329
12330
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
49 for(int32_t i=0; i<numnpcbindings; i++)
12331 {
12332 word id;
12333 12 p_igetw(&id, f);
12334 12 p_igetl(&bufsize, f);
12335
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if (bufsize < 0 || bufsize > 1024)
12336 return qe_invalid;
12337 12 buf = new char[bufsize+1];
12338 12 pfread(buf, bufsize, f);
12339 12 buf[bufsize]=0;
12340
12341 //fix this too
12342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(id <NUMSCRIPTGUYS-1)
12343 12 npcmap[id].scriptname = buf;
12344
12345
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 delete[] buf;
12346 12 }
12347 //lweapon
12348 word numlwpnbindings;
12349 37 p_igetw(&numlwpnbindings, f);
12350
12351
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 37 times.
79 for(int32_t i=0; i<numlwpnbindings; i++)
12352 {
12353 word id;
12354 42 p_igetw(&id, f);
12355 42 p_igetl(&bufsize, f);
12356
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if (bufsize < 0 || bufsize > 1024)
12357 return qe_invalid;
12358 42 buf = new char[bufsize+1];
12359 42 pfread(buf, bufsize, f);
12360 42 buf[bufsize]=0;
12361
12362 //fix this too
12363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(id <NUMSCRIPTWEAPONS-1)
12364 42 lwpnmap[id].scriptname = buf;
12365
12366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 delete[] buf;
12367 42 }
12368 //eweapon
12369 word numewpnbindings;
12370 37 p_igetw(&numewpnbindings, f);
12371
12372
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 37 times.
100 for(int32_t i=0; i<numewpnbindings; i++)
12373 {
12374 word id;
12375 63 p_igetw(&id, f);
12376 63 p_igetl(&bufsize, f);
12377
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
63 if (bufsize < 0 || bufsize > 1024)
12378 return qe_invalid;
12379 63 buf = new char[bufsize+1];
12380 63 pfread(buf, bufsize, f);
12381 63 buf[bufsize]=0;
12382
12383 //fix this too
12384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(id <NUMSCRIPTWEAPONS-1)
12385 63 ewpnmap[id].scriptname = buf;
12386
12387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
12388 63 }
12389 //hero
12390 word numherobindings;
12391 37 p_igetw(&numherobindings, f);
12392
12393
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 37 times.
42 for(int32_t i=0; i<numherobindings; i++)
12394 {
12395 word id;
12396 5 p_igetw(&id, f);
12397 5 p_igetl(&bufsize, f);
12398
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if (bufsize < 0 || bufsize > 1024)
12399 return qe_invalid;
12400 5 buf = new char[bufsize+1];
12401 5 pfread(buf, bufsize, f);
12402 5 buf[bufsize]=0;
12403
12404 //fix this too
12405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(id <NUMSCRIPTPLAYER-1)
12406 5 playermap[id].scriptname = buf;
12407
12408
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 delete[] buf;
12409 5 }
12410 //dmaps
12411 word numdmapbindings;
12412 37 p_igetw(&numdmapbindings, f);
12413
12414
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 37 times.
71 for(int32_t i=0; i<numdmapbindings; i++)
12415 {
12416 word id;
12417 34 p_igetw(&id, f);
12418 34 p_igetl(&bufsize, f);
12419
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 if (bufsize < 0 || bufsize > 1024)
12420 return qe_invalid;
12421 34 buf = new char[bufsize+1];
12422 34 pfread(buf, bufsize, f);
12423 34 buf[bufsize]=0;
12424
12425 //fix this too
12426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 if(id <NUMSCRIPTSDMAP-1)
12427 34 dmapmap[id].scriptname = buf;
12428
12429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 delete[] buf;
12430 34 }
12431 //screen
12432 word numscreenbindings;
12433 37 p_igetw(&numscreenbindings, f);
12434
12435
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 37 times.
75 for(int32_t i=0; i<numscreenbindings; i++)
12436 {
12437 word id;
12438 38 p_igetw(&id, f);
12439 38 p_igetl(&bufsize, f);
12440
2/4
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
38 if (bufsize < 0 || bufsize > 1024)
12441 return qe_invalid;
12442 38 buf = new char[bufsize+1];
12443 38 pfread(buf, bufsize, f);
12444 38 buf[bufsize]=0;
12445
12446 //fix this too
12447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(id <NUMSCRIPTSDMAP-1)
12448 38 screenmap[id].scriptname = buf;
12449
12450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 delete[] buf;
12451 38 }
12452 37 }
12453
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if(s_version > 11)
12454 {
12455 word numspritebindings;
12456 37 p_igetw(&numspritebindings, f);
12457
12458
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 37 times.
47 for(int32_t i=0; i<numspritebindings; i++)
12459 {
12460 word id;
12461 10 p_igetw(&id, f);
12462 10 p_igetl(&bufsize, f);
12463
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if (bufsize < 0 || bufsize > 1024)
12464 return qe_invalid;
12465 10 buf = new char[bufsize+1];
12466 10 pfread(buf, bufsize, f);
12467 10 buf[bufsize]=0;
12468
12469 //fix this too
12470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(id <NUMSCRIPTSDMAP-1)
12471 10 itemspritemap[id].scriptname = buf;
12472
12473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 delete[] buf;
12474 10 }
12475 37 }
12476
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if(s_version >= 15)
12477 {
12478 word numcombobindings;
12479 37 p_igetw(&numcombobindings, f);
12480
12481
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 37 times.
60 for(int32_t i=0; i<numcombobindings; i++)
12482 {
12483 word id;
12484 23 p_igetw(&id, f);
12485 23 p_igetl(&bufsize, f);
12486
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if (bufsize < 0 || bufsize > 1024)
12487 return qe_invalid;
12488 23 buf = new char[bufsize+1];
12489 23 pfread(buf, bufsize, f);
12490 23 buf[bufsize]=0;
12491
12492 //fix this too
12493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTSCOMBODATA-1)
12494 23 comboscriptmap[id].scriptname = buf;
12495
12496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 delete[] buf;
12497 23 }
12498 37 }
12499
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if(s_version > 19)
12500 {
12501 word numgenericbindings;
12502 37 p_igetw(&numgenericbindings, f);
12503
12504
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 37 times.
50 for(int32_t i=0; i<numgenericbindings; i++)
12505 {
12506 word id;
12507 13 p_igetw(&id, f);
12508 13 p_igetl(&bufsize, f);
12509
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if (bufsize < 0 || bufsize > 1024)
12510 return qe_invalid;
12511 13 buf = new char[bufsize+1];
12512 13 pfread(buf, bufsize, f);
12513 13 buf[bufsize]=0;
12514
12515 //fix this too
12516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(id <NUMSCRIPTSGENERIC-1)
12517 13 genericmap[id].scriptname = buf;
12518
12519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 delete[] buf;
12520 13 }
12521 37 }
12522
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 8 times.
114 if(s_version > 21)
12523 {
12524 word numsubscreenbindings;
12525 8 p_igetw(&numsubscreenbindings, f);
12526
12527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 for(int32_t i=0; i<numsubscreenbindings; i++)
12528 {
12529 word id;
12530 p_igetw(&id, f);
12531 p_igetl(&bufsize, f);
12532 if (bufsize < 0 || bufsize > 1024)
12533 return qe_invalid;
12534 buf = new char[bufsize+1];
12535 pfread(buf, bufsize, f);
12536 buf[bufsize]=0;
12537
12538 //fix this too
12539 if(id <NUMSCRIPTSSUBSCREEN-1)
12540 subscreenmap[id].scriptname = buf;
12541
12542 delete[] buf;
12543 }
12544 8 }
12545 114 }
12546
12547 114 return 0;
12548 114 }
12549
12550 130 void reset_scripts()
12551 {
12552 #ifdef IS_PLAYER
12553 // We can't modify the script data while jit threads are possibly compiling them.
12554 void jit_shutdown();
12555 130 jit_shutdown();
12556 #endif
12557
12558 130 next_script_data_debug_id = 0;
12559
12560
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 130 times.
66690 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12561 {
12562
2/2
✓ Branch 0 taken 7168 times.
✓ Branch 1 taken 59392 times.
66560 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12563
1/2
✓ Branch 0 taken 59392 times.
✗ Branch 1 not taken.
59392 else genericscripts[i] = new script_data();
12564 66560 }
12565
12566
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 130 times.
66690 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12567 {
12568
1/2
✓ Branch 0 taken 66560 times.
✗ Branch 1 not taken.
66560 if(ffscripts[i]!=NULL)
12569 {
12570 66560 ffscripts[i]->disable();
12571 66560 }
12572 else
12573 {
12574 ffscripts[i] = new script_data();
12575 }
12576 66560 }
12577
12578
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12579 {
12580
1/2
✓ Branch 0 taken 33280 times.
✗ Branch 1 not taken.
33280 if(itemscripts[i]!=NULL)
12581 {
12582 33280 itemscripts[i]->disable();
12583 33280 }
12584 else
12585 {
12586 itemscripts[i] = new script_data();
12587 }
12588 33280 }
12589
12590
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12591 {
12592
1/2
✓ Branch 0 taken 33280 times.
✗ Branch 1 not taken.
33280 if(guyscripts[i]!=NULL)
12593 {
12594 33280 guyscripts[i]->disable();
12595 33280 }
12596 else
12597 {
12598 guyscripts[i] = new script_data();
12599 }
12600 33280 }
12601
12602
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12603 {
12604
1/2
✓ Branch 0 taken 33280 times.
✗ Branch 1 not taken.
33280 if(wpnscripts[i]!=NULL)
12605 {
12606 33280 wpnscripts[i]->disable();
12607 33280 }
12608 else
12609 {
12610 wpnscripts[i] = new script_data();
12611 }
12612 33280 }
12613
12614
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12615 {
12616
1/2
✓ Branch 0 taken 33280 times.
✗ Branch 1 not taken.
33280 if(screenscripts[i]!=NULL)
12617 {
12618 33280 screenscripts[i]->disable();
12619 33280 }
12620 else
12621 {
12622 screenscripts[i] = new script_data();
12623 }
12624 33280 }
12625
12626
2/2
✓ Branch 0 taken 1040 times.
✓ Branch 1 taken 130 times.
1170 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12627 {
12628
1/2
✓ Branch 0 taken 1040 times.
✗ Branch 1 not taken.
1040 if(globalscripts[i]!=NULL)
12629 {
12630 1040 globalscripts[i]->disable();
12631 1040 }
12632 else
12633 {
12634 globalscripts[i] = new script_data();
12635 }
12636 1040 }
12637
12638
2/2
✓ Branch 0 taken 650 times.
✓ Branch 1 taken 130 times.
780 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12639 {
12640
1/2
✓ Branch 0 taken 650 times.
✗ Branch 1 not taken.
650 if(playerscripts[i]!=NULL)
12641 {
12642 650 playerscripts[i]->disable();
12643 650 }
12644 else
12645 {
12646 playerscripts[i] = new script_data();
12647 }
12648 650 }
12649
12650
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12651 {
12652
1/2
✓ Branch 0 taken 33280 times.
✗ Branch 1 not taken.
33280 if(lwpnscripts[i]!=NULL)
12653 {
12654 33280 lwpnscripts[i]->disable();
12655 33280 }
12656 else
12657 {
12658 lwpnscripts[i] = new script_data();
12659 }
12660 33280 }
12661
12662
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12663 {
12664
1/2
✓ Branch 0 taken 33280 times.
✗ Branch 1 not taken.
33280 if(ewpnscripts[i]!=NULL)
12665 {
12666 33280 ewpnscripts[i]->disable();
12667 33280 }
12668 else
12669 {
12670 ewpnscripts[i] = new script_data();
12671 }
12672 33280 }
12673
12674
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12675 {
12676
1/2
✓ Branch 0 taken 33280 times.
✗ Branch 1 not taken.
33280 if(dmapscripts[i]!=NULL)
12677 {
12678 33280 dmapscripts[i]->disable();
12679 33280 }
12680 else
12681 {
12682 dmapscripts[i] = new script_data();
12683 }
12684 33280 }
12685
12686
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12687 {
12688
1/2
✓ Branch 0 taken 33280 times.
✗ Branch 1 not taken.
33280 if(itemspritescripts[i]!=NULL)
12689 {
12690 33280 itemspritescripts[i]->disable();
12691 33280 }
12692 else
12693 {
12694 itemspritescripts[i] = new script_data();
12695 }
12696 33280 }
12697
12698
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 130 times.
66690 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12699 {
12700
1/2
✓ Branch 0 taken 66560 times.
✗ Branch 1 not taken.
66560 if(comboscripts[i]!=NULL)
12701 {
12702 66560 comboscripts[i]->disable();
12703 66560 }
12704 else
12705 {
12706 comboscripts[i] = new script_data();
12707 }
12708 66560 }
12709
12710
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12711 {
12712
1/2
✓ Branch 0 taken 33280 times.
✗ Branch 1 not taken.
33280 if(subscreenscripts[i]!=NULL)
12713 {
12714 33280 subscreenscripts[i]->disable();
12715 33280 }
12716 else
12717 {
12718 subscreenscripts[i] = new script_data();
12719 }
12720 33280 }
12721 130 }
12722
12723 extern script_command command_list[];
12724 253948 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, word , script_data **script, word zmeta_version)
12725 {
12726 //Please also update loadquest() when modifying this method -DD
12727 253948 char b33[34] = {0};
12728 253948 b33[33] = 0;
12729 253948 ffscript temp_script;
12730 253948 int32_t num_commands=1000;
12731
12732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253948 times.
253948 if(s_version>=2)
12733 {
12734
2/4
✓ Branch 0 taken 253948 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253948 times.
✗ Branch 3 not taken.
253948 if(!p_igetl(&num_commands,f))
12735 {
12736 return qe_invalid;
12737 }
12738 253948 }
12739
12740 #ifdef ZC_FUZZ
12741 const int32_t command_limit = 300000;
12742 #else
12743 253948 const int32_t command_limit = 10000000;
12744 #endif
12745
2/4
✓ Branch 0 taken 253948 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253948 times.
✗ Branch 3 not taken.
253948 if (num_commands < 0 || num_commands > command_limit)
12746 {
12747 return qe_invalid;
12748 }
12749
12750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253948 times.
253948 if((*script) != NULL)
12751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253948 times.
253948 delete (*script);
12752
2/4
✓ Branch 0 taken 253948 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253948 times.
✗ Branch 3 not taken.
253948 (*script) = new script_data(num_commands);
12753
12754
2/2
✓ Branch 0 taken 135137 times.
✓ Branch 1 taken 118811 times.
253948 if(s_version >= 16)
12755 {
12756
1/2
✓ Branch 0 taken 135137 times.
✗ Branch 1 not taken.
135137 zasm_meta temp_meta;
12757
12758
2/4
✓ Branch 0 taken 135137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135137 times.
✗ Branch 3 not taken.
135137 if(!p_igetw(&(temp_meta.zasm_v),f))
12759 {
12760 return qe_invalid;
12761 }
12762
12763
2/4
✓ Branch 0 taken 135137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135137 times.
✗ Branch 3 not taken.
135137 if(!p_igetw(&(temp_meta.meta_v),f))
12764 {
12765 return qe_invalid;
12766 }
12767
12768
2/4
✓ Branch 0 taken 135137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135137 times.
✗ Branch 3 not taken.
135137 if(!p_igetw(&(temp_meta.ffscript_v),f))
12769 {
12770 return qe_invalid;
12771 }
12772
12773
2/4
✓ Branch 0 taken 135137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135137 times.
✗ Branch 3 not taken.
135137 if(!p_getc(&(temp_meta.script_type),f))
12774 {
12775 return qe_invalid;
12776 }
12777
12778
2/2
✓ Branch 0 taken 1081096 times.
✓ Branch 1 taken 135137 times.
1216233 for(int32_t q = 0; q < 8; ++q)
12779 {
12780
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1023544 times.
1081096 if(zmeta_version < 3)
12781 {
12782
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1899216 times.
1956768 for(int32_t c = 0; c < 33; ++c)
12783 {
12784
2/4
✓ Branch 0 taken 1899216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1899216 times.
✗ Branch 3 not taken.
1899216 if(!p_getc(&(b33[c]),f))
12785 {
12786 return qe_invalid;
12787 }
12788 1899216 }
12789
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.run_idens[q].assign(b33);
12790 57552 }
12791 else
12792 {
12793
2/4
✓ Branch 0 taken 1023544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1023544 times.
✗ Branch 3 not taken.
1023544 if(!p_getcstr(&temp_meta.run_idens[q],f))
12794 {
12795 return qe_invalid;
12796 }
12797 }
12798 1081096 }
12799
12800
2/2
✓ Branch 0 taken 135137 times.
✓ Branch 1 taken 1081096 times.
1216233 for(int32_t q = 0; q < 8; ++q)
12801 {
12802
2/4
✓ Branch 0 taken 1081096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1081096 times.
✗ Branch 3 not taken.
1081096 if(!p_getc(&(temp_meta.run_types[q]),f))
12803 {
12804 return qe_invalid;
12805 }
12806 1081096 }
12807
12808
2/4
✓ Branch 0 taken 135137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135137 times.
✗ Branch 3 not taken.
135137 if(!p_getc(&(temp_meta.flags),f))
12809 {
12810 return qe_invalid;
12811 }
12812
12813
2/4
✓ Branch 0 taken 135137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135137 times.
✗ Branch 3 not taken.
135137 if(!p_igetw(&(temp_meta.compiler_v1),f))
12814 {
12815 return qe_invalid;
12816 }
12817
12818
2/4
✓ Branch 0 taken 135137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135137 times.
✗ Branch 3 not taken.
135137 if(!p_igetw(&(temp_meta.compiler_v2),f))
12819 {
12820 return qe_invalid;
12821 }
12822
12823
2/4
✓ Branch 0 taken 135137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135137 times.
✗ Branch 3 not taken.
135137 if(!p_igetw(&(temp_meta.compiler_v3),f))
12824 {
12825 return qe_invalid;
12826 }
12827
12828
2/4
✓ Branch 0 taken 135137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135137 times.
✗ Branch 3 not taken.
135137 if(!p_igetw(&(temp_meta.compiler_v4),f))
12829 {
12830 return qe_invalid;
12831 }
12832
12833
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 127943 times.
135137 if(zmeta_version == 2)
12834 {
12835
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
12836 {
12837
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
12838 {
12839 return qe_invalid;
12840 }
12841 237402 }
12842
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.script_name.assign(b33);
12843
12844
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
12845 {
12846
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
12847 {
12848 return qe_invalid;
12849 }
12850 237402 }
12851
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.author.assign(b33);
12852 7194 }
12853
1/2
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
127943 else if(zmeta_version > 2)
12854 {
12855
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_getcstr(&temp_meta.script_name,f))
12856 return qe_invalid;
12857
2/4
✓ Branch 0 taken 127943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127943 times.
✗ Branch 3 not taken.
127943 if(!p_getcstr(&temp_meta.author,f))
12858 return qe_invalid;
12859 127943 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
12860
2/2
✓ Branch 0 taken 1279430 times.
✓ Branch 1 taken 127943 times.
1407373 for(auto q = 0; q < num_meta_attrib; ++q)
12861 {
12862
2/4
✓ Branch 0 taken 1279430 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1279430 times.
✗ Branch 3 not taken.
1279430 if(!p_getcstr(&temp_meta.attributes[q],f))
12863 return qe_invalid;
12864
2/4
✓ Branch 0 taken 1279430 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1279430 times.
✗ Branch 3 not taken.
1279430 if(!p_getwstr(&temp_meta.attributes_help[q],f))
12865 return qe_invalid;
12866 1279430 }
12867
2/2
✓ Branch 0 taken 1023544 times.
✓ Branch 1 taken 127943 times.
1151487 for(auto q = 0; q < 8; ++q)
12868 {
12869
2/4
✓ Branch 0 taken 1023544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1023544 times.
✗ Branch 3 not taken.
1023544 if(!p_getcstr(&temp_meta.attribytes[q],f))
12870 return qe_invalid;
12871
2/4
✓ Branch 0 taken 1023544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1023544 times.
✗ Branch 3 not taken.
1023544 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
12872 return qe_invalid;
12873 1023544 }
12874
2/2
✓ Branch 0 taken 1023544 times.
✓ Branch 1 taken 127943 times.
1151487 for(auto q = 0; q < 8; ++q)
12875 {
12876
2/4
✓ Branch 0 taken 1023544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1023544 times.
✗ Branch 3 not taken.
1023544 if(!p_getcstr(&temp_meta.attrishorts[q],f))
12877 return qe_invalid;
12878
2/4
✓ Branch 0 taken 1023544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1023544 times.
✗ Branch 3 not taken.
1023544 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
12879 return qe_invalid;
12880 1023544 }
12881
2/2
✓ Branch 0 taken 2047088 times.
✓ Branch 1 taken 127943 times.
2175031 for(auto q = 0; q < 16; ++q)
12882 {
12883
2/4
✓ Branch 0 taken 2047088 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2047088 times.
✗ Branch 3 not taken.
2047088 if(!p_getcstr(&temp_meta.usrflags[q],f))
12884 return qe_invalid;
12885
2/4
✓ Branch 0 taken 2047088 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2047088 times.
✗ Branch 3 not taken.
2047088 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
12886 return qe_invalid;
12887 2047088 }
12888 127943 }
12889
2/2
✓ Branch 0 taken 127943 times.
✓ Branch 1 taken 7194 times.
135137 if(zmeta_version > 3)
12890 {
12891
2/2
✓ Branch 0 taken 1023544 times.
✓ Branch 1 taken 127943 times.
1151487 for(auto q = 0; q < 8; ++q)
12892 {
12893
2/4
✓ Branch 0 taken 1023544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1023544 times.
✗ Branch 3 not taken.
1023544 if(!p_getcstr(&temp_meta.initd[q],f))
12894 return qe_invalid;
12895
2/4
✓ Branch 0 taken 1023544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1023544 times.
✗ Branch 3 not taken.
1023544 if(!p_getwstr(&temp_meta.initd_help[q],f))
12896 return qe_invalid;
12897 1023544 }
12898
2/2
✓ Branch 0 taken 1023544 times.
✓ Branch 1 taken 127943 times.
1151487 for(auto q = 0; q < 8; ++q)
12899 {
12900
2/4
✓ Branch 0 taken 1023544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1023544 times.
✗ Branch 3 not taken.
1023544 if(!p_getc(&temp_meta.initd_type[q],f))
12901 return qe_invalid;
12902 1023544 }
12903 127943 }
12904 else
12905 {
12906
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
12907 {
12908
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.initd[q] = temp_meta.run_idens[q];
12909 57552 }
12910 }
12911
12912
1/2
✓ Branch 0 taken 135137 times.
✗ Branch 1 not taken.
135137 (*script)->meta = temp_meta;
12913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135137 times.
135137 }
12914
12915
1/2
✓ Branch 0 taken 253948 times.
✗ Branch 1 not taken.
253948 temp_script.clear();
12916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21851114 times.
21851114 for(int32_t j=0; j<num_commands; j++)
12917 {
12918
2/4
✓ Branch 0 taken 21851114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21851114 times.
✗ Branch 3 not taken.
21851114 if(!p_igetw(&(temp_script.command),f))
12919 {
12920 return qe_invalid;
12921 }
12922
12923
2/2
✓ Branch 0 taken 253948 times.
✓ Branch 1 taken 21597166 times.
21851114 if(temp_script.command == 0xFFFF)
12924 {
12925
1/2
✓ Branch 0 taken 253948 times.
✗ Branch 1 not taken.
253948 (*script)->zasm[j].clear();
12926 253948 break;
12927 }
12928 else
12929 {
12930
2/4
✓ Branch 0 taken 21597166 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21597166 times.
✗ Branch 3 not taken.
21597166 if(!p_igetl(&(temp_script.arg1),f))
12931 {
12932 return qe_invalid;
12933 }
12934
12935
2/4
✓ Branch 0 taken 21597166 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21597166 times.
✗ Branch 3 not taken.
21597166 if(!p_igetl(&(temp_script.arg2),f))
12936 {
12937 return qe_invalid;
12938 }
12939
12940
2/2
✓ Branch 0 taken 924545 times.
✓ Branch 1 taken 20672621 times.
21597166 if(s_version >= 21)
12941 {
12942 924545 uint32_t sz = 0;
12943
2/4
✓ Branch 0 taken 924545 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 924545 times.
✗ Branch 3 not taken.
924545 if(!p_igetl(&sz,f))
12944 {
12945 return qe_invalid;
12946 }
12947
2/2
✓ Branch 0 taken 3240 times.
✓ Branch 1 taken 921305 times.
924545 if(sz) //string found
12948 {
12949
1/2
✓ Branch 0 taken 3240 times.
✗ Branch 1 not taken.
3240 temp_script.strptr = new std::string();
12950 char dummy;
12951
2/2
✓ Branch 0 taken 233480 times.
✓ Branch 1 taken 3240 times.
236720 for(size_t q = 0; q < sz; ++q)
12952 {
12953
2/4
✓ Branch 0 taken 233480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 233480 times.
✗ Branch 3 not taken.
233480 if(!p_getc(&dummy,f))
12954 {
12955 return qe_invalid;
12956 }
12957
1/2
✓ Branch 0 taken 233480 times.
✗ Branch 1 not taken.
233480 temp_script.strptr->push_back(dummy);
12958 233480 }
12959 3240 }
12960
2/4
✓ Branch 0 taken 924545 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 924545 times.
✗ Branch 3 not taken.
924545 if(!p_igetl(&sz,f))
12961 {
12962 return qe_invalid;
12963 }
12964
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 924444 times.
924545 if(sz) //vector found
12965 {
12966
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 temp_script.vecptr = new std::vector<int32_t>();
12967 int32_t dummy;
12968
2/2
✓ Branch 0 taken 1487 times.
✓ Branch 1 taken 101 times.
1588 for(size_t q = 0; q < sz; ++q)
12969 {
12970
2/4
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1487 times.
✗ Branch 3 not taken.
1487 if(!p_igetl(&dummy,f))
12971 {
12972 return qe_invalid;
12973 }
12974
1/2
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
1487 temp_script.vecptr->push_back(dummy);
12975 1487 }
12976 101 }
12977 924545 }
12978
12979
1/2
✓ Branch 0 taken 21597166 times.
✗ Branch 1 not taken.
21597166 temp_script.give((*script)->zasm[j]);
12980 }
12981
1/2
✓ Branch 0 taken 21597166 times.
✗ Branch 1 not taken.
21597166 temp_script.clear();
12982 21597166 }
12983
12984 253948 return 0;
12985 253948 }
12986
12987 extern SAMPLE customsfxdata[WAV_COUNT];
12988 extern uint8_t customsfxflag[WAV_COUNT>>3];
12989 extern int32_t sfxdat;
12990 extern DATAFILE *sfxdata;
12991 const char *old_sfx_string[Z35] =
12992 {
12993 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
12994 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
12995 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
12996 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
12997 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
12998 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
12999 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13000 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13001 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13002 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13003 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13004 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13005 };
13006 char *sfx_string[WAV_COUNT];
13007
13008 114 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13009 {
13010 //these are here to bypass compiler warnings about unused arguments
13011 114 Header=Header;
13012
13013 int32_t dummy;
13014 114 word s_version=0, s_cversion=0;
13015 //int32_t ret;
13016 SAMPLE temp_sample;
13017 114 temp_sample.loop_start=0;
13018 114 temp_sample.loop_end=0;
13019 114 temp_sample.param=0;
13020
13021 //section version info
13022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_igetw(&s_version,f))
13023 {
13024 return qe_invalid;
13025 }
13026
13027 114 FFCore.quest_format[vSFX] = s_version;
13028
13029 //al_trace("SFX version %d\n", s_version);
13030
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&s_cversion,f))
13031 {
13032 return qe_invalid;
13033 }
13034
13035 //section size
13036
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&dummy,f))
13037 {
13038 return qe_invalid;
13039 }
13040
13041 /* HIGHLY UNORTHODOX UPDATING THING, by L
13042 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13043 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13044 * changing from 1 to 2.
13045 */
13046
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(s_version < 2)
13047 set_qr(qr_GOTOLESSNOTEQUAL,1);
13048
13049 /* End highly unorthodox updating thing */
13050
13051 114 int32_t wavcount = WAV_COUNT;
13052
13053
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(s_version < 6)
13054 wavcount = 128;
13055
13056 uint8_t tempflag[WAV_COUNT>>3];
13057
13058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(s_version < 4)
13059 {
13060 memset(tempflag, 0xFF, WAV_COUNT>>3);
13061 }
13062 else
13063 {
13064
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(s_version < 6)
13065 memset(tempflag, 0, WAV_COUNT>>3);
13066
13067
2/2
✓ Branch 0 taken 3648 times.
✓ Branch 1 taken 114 times.
3762 for(int32_t i=0; i<(wavcount>>3); i++)
13068 {
13069 3648 p_getc(&tempflag[i], f);
13070 3648 }
13071
13072 }
13073
13074
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(s_version>4)
13075 {
13076
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=1; i<WAV_COUNT; i++)
13077 {
13078 29070 sprintf(sfx_string[i],"s%03d",i);
13079
13080
2/2
✓ Branch 0 taken 22230 times.
✓ Branch 1 taken 6840 times.
29070 if((i<Z35))
13081 6840 strcpy(sfx_string[i], old_sfx_string[i-1]);
13082
13083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29070 times.
29070 if(i>=wavcount)
13084 continue;
13085
2/2
✓ Branch 0 taken 3145 times.
✓ Branch 1 taken 25925 times.
29070 if(get_bit(tempflag, i-1))
13086 {
13087 char tempname[36];
13088
13089
1/2
✓ Branch 0 taken 3145 times.
✗ Branch 1 not taken.
3145 if(!pfread(tempname, 36, f))
13090 {
13091 return qe_invalid;
13092 }
13093
13094 3145 sfx_string[i][0] = '\0';
13095 3145 strncat(sfx_string[i], tempname, 36 - 1);
13096 3145 }
13097 else
13098 {
13099 25925 sprintf(sfx_string[i],"s%03d",i);
13100
13101
2/2
✓ Branch 0 taken 21347 times.
✓ Branch 1 taken 4578 times.
25925 if(i<Z35)
13102 4578 strcpy(sfx_string[i], old_sfx_string[i-1]);
13103 25925 sfx_string[i][35] = 0; //Force NULL Termination
13104 }
13105 29070 }
13106 114 }
13107 else
13108 {
13109 for(int32_t i=1; i<WAV_COUNT; i++)
13110 {
13111 sprintf(sfx_string[i],"s%03d",i);
13112
13113 if(i<Z35)
13114 strcpy(sfx_string[i], old_sfx_string[i-1]);
13115 }
13116 }
13117
13118 //finally... section data
13119
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=1; i<wavcount; i++)
13120 {
13121
2/2
✓ Branch 0 taken 3145 times.
✓ Branch 1 taken 25925 times.
29070 if(get_bit(tempflag, i-1))
13122 {
13123
13124
1/2
✓ Branch 0 taken 3145 times.
✗ Branch 1 not taken.
3145 if(!p_igetl(&dummy,f))
13125 {
13126 return qe_invalid;
13127 }
13128
13129 3145 (temp_sample.bits) = dummy;
13130
13131
1/2
✓ Branch 0 taken 3145 times.
✗ Branch 1 not taken.
3145 if(!p_igetl(&dummy,f))
13132 {
13133 return qe_invalid;
13134 }
13135
13136 3145 (temp_sample.stereo) = dummy;
13137
13138
1/2
✓ Branch 0 taken 3145 times.
✗ Branch 1 not taken.
3145 if(!p_igetl(&dummy,f))
13139 {
13140 return qe_invalid;
13141 }
13142
13143 3145 (temp_sample.freq) = dummy;
13144
13145
1/2
✓ Branch 0 taken 3145 times.
✗ Branch 1 not taken.
3145 if(!p_igetl(&dummy,f))
13146 {
13147 return qe_invalid;
13148 }
13149
13150 3145 (temp_sample.priority) = dummy;
13151
13152
1/2
✓ Branch 0 taken 3145 times.
✗ Branch 1 not taken.
3145 if(!p_igetl(&(temp_sample.len),f))
13153 {
13154 return qe_invalid;
13155 }
13156
13157
1/2
✓ Branch 0 taken 3145 times.
✗ Branch 1 not taken.
3145 if(!p_igetl(&(temp_sample.loop_start),f))
13158 {
13159 return qe_invalid;
13160 }
13161
13162
1/2
✓ Branch 0 taken 3145 times.
✗ Branch 1 not taken.
3145 if(!p_igetl(&(temp_sample.loop_end),f))
13163 {
13164 return qe_invalid;
13165 }
13166
13167
1/2
✓ Branch 0 taken 3145 times.
✗ Branch 1 not taken.
3145 if(!p_igetl(&(temp_sample.param),f))
13168 {
13169 return qe_invalid;
13170 }
13171
13172 // al_trace("F%i: L%i\n",i,temp_sample.len);
13173 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13174 3145 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13175
2/4
✓ Branch 0 taken 3145 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3145 times.
3145 if (len < 0 || len > 10000000)
13176 {
13177 return qe_invalid;
13178 }
13179 3145 temp_sample.data = calloc(len,1);
13180
13181
1/2
✓ Branch 0 taken 3145 times.
✗ Branch 1 not taken.
3145 if(s_version < 3)
13182 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13183
13184 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3145 times.
3145 if(s_version < 2)
13186 {
13187 if(!pfread(temp_sample.data, len,f))
13188 {
13189 return qe_invalid;
13190 }
13191 }
13192 else
13193 {
13194 //re-endianfy the data
13195 3145 int32_t wordstoread = len / sizeof(word);
13196
13197
2/2
✓ Branch 0 taken 90979314 times.
✓ Branch 1 taken 3145 times.
90982459 for(int32_t j=0; j<wordstoread; j++)
13198 {
13199 word temp;
13200
13201
1/2
✓ Branch 0 taken 90979314 times.
✗ Branch 1 not taken.
90979314 if(!p_igetw(&temp, f))
13202 {
13203 return qe_invalid;
13204 }
13205
13206 90979314 ((word *)temp_sample.data)[j] = temp;
13207 90979314 }
13208 }
13209 3145 }
13210
2/2
✓ Branch 0 taken 4578 times.
✓ Branch 1 taken 21347 times.
25925 else if(i < Z35)
13211 {
13212 4578 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13213 4578 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13214 4578 set_bit(tempflag, i-1, 1);
13215 4578 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13216 4578 temp_sample.data = calloc(len,1);
13217 4578 memcpy(temp_sample.data, datsamp->data, len);
13218 4578 }
13219 21347 else continue;
13220
13221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7723 times.
7723 if(customsfxdata[i].data!=NULL)
13222 {
13223 // delete [] customsfxdata[i].data;
13224 7723 free(customsfxdata[i].data);
13225 7723 }
13226
13227 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13228 7723 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13229 7723 customsfxdata[i].data = calloc(len2,1);
13230 7723 customsfxdata[i].bits = temp_sample.bits;
13231 7723 customsfxdata[i].stereo = temp_sample.stereo;
13232 7723 customsfxdata[i].freq = temp_sample.freq;
13233 7723 customsfxdata[i].priority = temp_sample.priority;
13234 7723 customsfxdata[i].len = temp_sample.len;
13235 7723 customsfxdata[i].loop_start = temp_sample.loop_start;
13236 7723 customsfxdata[i].loop_end = temp_sample.loop_end;
13237 7723 customsfxdata[i].param = temp_sample.param;
13238 7723 int32_t cpylen = len2;
13239
13240
1/2
✓ Branch 0 taken 7723 times.
✗ Branch 1 not taken.
7723 if(s_version<3)
13241 {
13242 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13243 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13244 }
13245
13246 7723 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13247
13248 7723 free(temp_sample.data);
13249 7723 }
13250
13251 114 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13252
13253 114 sfxdat=0;
13254 114 return 0;
13255 114 }
13256
13257 130 void setupsfx()
13258 {
13259
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=1; i<WAV_COUNT; i++)
13260 {
13261 33150 sprintf(sfx_string[i],"s%03d",i);
13262
13263
2/2
✓ Branch 0 taken 25350 times.
✓ Branch 1 taken 7800 times.
33150 if(i<Z35)
13264 {
13265 7800 strcpy(sfx_string[i], old_sfx_string[i-1]);
13266 7800 }
13267
13268 33150 memset(customsfxflag, 0, WAV_COUNT>>3);
13269
13270 33150 int32_t j=i;
13271
13272
2/2
✓ Branch 0 taken 7930 times.
✓ Branch 1 taken 25220 times.
33150 if(i>Z35)
13273 {
13274 25220 i=Z35;
13275 25220 }
13276
13277 33150 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13278
13279
2/2
✓ Branch 0 taken 29580 times.
✓ Branch 1 taken 3570 times.
33150 if(customsfxdata[j].data!=NULL)
13280 {
13281 // delete [] customsfxdata[j].data;
13282 3570 free(customsfxdata[j].data);
13283 3570 }
13284
13285 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13286 33150 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13287 33150 customsfxdata[j].bits = temp_sample->bits;
13288 33150 customsfxdata[j].stereo = temp_sample->stereo;
13289 33150 customsfxdata[j].freq = temp_sample->freq;
13290 33150 customsfxdata[j].priority = temp_sample->priority;
13291 33150 customsfxdata[j].len = temp_sample->len;
13292 33150 customsfxdata[j].loop_start = temp_sample->loop_start;
13293 33150 customsfxdata[j].loop_end = temp_sample->loop_end;
13294 33150 customsfxdata[j].param = temp_sample->param;
13295 33150 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13296 33150 i=j;
13297 33150 }
13298 130 }
13299
13300 extern char *guy_string[eMAXGUYS];
13301 extern const char *old_guy_string[OLDMAXGUYS];
13302
13303 130 int32_t readguys(PACKFILE *f, zquestheader *Header)
13304 {
13305 dword dummy;
13306 word guy_cversion;
13307 130 word guyversion=0;
13308
13309
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version >= 0x193)
13310 {
13311 //section version info
13312
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&guyversion,f))
13313 {
13314 return qe_invalid;
13315 }
13316
13317 126 FFCore.quest_format[vGuys] = guyversion;
13318
13319 //al_trace("Guys version %d\n", guyversion);
13320
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&guy_cversion,f))
13321 {
13322 return qe_invalid;
13323 }
13324 126 al_trace("Guy CVersion is: %d\n", guy_cversion);
13325 //section size
13326
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy,f))
13327 {
13328 return qe_invalid;
13329 }
13330 126 }
13331
13332
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(guyversion > 3)
13333 {
13334
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<MAXGUYS; i++)
13335 {
13336 char tempname[64];
13337
13338 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13339 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13340
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58368 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58368 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13341 {
13342 memset(tempname, 0, sizeof(char)*64);
13343 sprintf(tempname, "e%03d", i);
13344 strcpy(guy_string[i], tempname);
13345
13346 continue;
13347 }
13348
13349
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!pfread(tempname, 64, f))
13350 {
13351 return qe_invalid;
13352 }
13353
13354 // Don't retain names of uneditable enemy entries!
13355 // for version upgrade to 2.5
13356
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58368 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58368 if(guyversion < 23 && i >= 177)
13357 {
13358 // some of the older builds have names such as 'zz123',
13359 // (this order gets messed up with some eXXX and some zzXXX)
13360 // so let's update to the newer naming convection. -Gleeok
13361 char tmpbuf[64];
13362 memset(tmpbuf, 0, sizeof(char)*64);
13363 sprintf(tmpbuf, "zz%03d", i);
13364
13365 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13366 {
13367 memset(tempname, 0, sizeof(char)*64);
13368 sprintf(tempname, "e%03d", i);
13369 }
13370 }
13371
13372
6/6
✓ Branch 0 taken 20178 times.
✓ Branch 1 taken 38190 times.
✓ Branch 2 taken 19152 times.
✓ Branch 3 taken 1026 times.
✓ Branch 4 taken 16118 times.
✓ Branch 5 taken 3034 times.
58368 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13373 {
13374 55334 guy_string[i][0] = '\0';
13375 55334 strncat(guy_string[i], tempname, 64 - 1);
13376 55334 }
13377 else
13378 {
13379 3034 strcpy(guy_string[i],old_guy_string[i]);
13380 }
13381 58368 }
13382 114 }
13383 else
13384 {
13385
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 16 times.
8208 for(int32_t i=0; i<eMAXGUYS; i++)
13386 {
13387 8192 sprintf(guy_string[i],"zz%03d",i);
13388 8192 }
13389
13390
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 16 times.
2848 for(int32_t i=0; i<OLDMAXGUYS; i++)
13391 {
13392 2832 strcpy(guy_string[i],old_guy_string[i]);
13393 2832 }
13394 }
13395
13396
13397 //finally... section data
13398 130 init_guys(guyversion); //using default data for now...
13399
13400 // Goriya guy fix
13401
3/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13402 {
13403
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(get_qr(qr_NEWENEMYTILES))
13404 {
13405 12 guysbuf[gGORIYA].tile=130;
13406 12 guysbuf[gGORIYA].e_tile=130;
13407 12 }
13408 16 }
13409
13410
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(Header->zelda_version < 0x193)
13411 {
13412
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(deprecated_rules,46))
13413 {
13414 guysbuf[eDODONGO].cset=14;
13415 guysbuf[eDODONGO].bosspal=spDIG;
13416 }
13417 4 }
13418 // Not sure when this first changed, but it's necessary for 2.10, at least
13419 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13420 //2.10 Fixes
13421
3/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13422 {
13423 16 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13424 16 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13425 16 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13426 16 guysbuf[eCENT1].misc3 = 1;
13427 16 guysbuf[eCENT2].misc3 = 1;
13428 16 }
13429
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13430 {
13431 130 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13432 130 }
13433
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(Header->zelda_version <= 0x210)
13434 {
13435 16 guysbuf[eGLEEOK1F].misc6 = 16;
13436 16 guysbuf[eGLEEOK2F].misc6 = 16;
13437 16 guysbuf[eGLEEOK3F].misc6 = 16;
13438 16 guysbuf[eGLEEOK4F].misc6 = 16;
13439
13440 16 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13441 16 guysbuf[eBATROBE].misc4 = 1;
13442 //guysbuf[eSUMMONER].misc4 = 1;
13443 16 guysbuf[eWWIZ].misc4 = 1;
13444 16 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13445 16 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13446 16 }
13447
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(Header->zelda_version == 0x190)
13448 {
13449 4 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13450 4 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13451 4 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13452 4 }
13453
13454 // The versions here may not be correct
13455 // zelda_version>=0x211 handled at guyversion<24
13456
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version <= 0x190)
13457 {
13458 4 guysbuf[eCENT1].misc3 = 0;
13459 4 guysbuf[eCENT2].misc3 = 0;
13460 4 guysbuf[eMOLDORM].misc2 = 0;
13461 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13462 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13463 4 }
13464
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
126 else if(Header->zelda_version <= 0x210)
13465 {
13466 12 guysbuf[eCENT1].misc3 = 1;
13467 12 guysbuf[eCENT2].misc3 = 1;
13468 12 guysbuf[eMOLDORM].misc2 = 0;
13469 12 }
13470
13471
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13472 {
13473 16 guysbuf[eKEESE1].misc16 = 120;
13474 16 guysbuf[eKEESE2].misc16 = 120;
13475 16 guysbuf[eKEESE3].misc16 = 120;
13476 16 guysbuf[eKEESETRIB].misc16 = 120;
13477 16 guysbuf[eKEESE1].misc17 = 16;
13478 16 guysbuf[eKEESE2].misc17 = 16;
13479 16 guysbuf[eKEESE3].misc17 = 16;
13480 16 guysbuf[eKEESETRIB].misc17 = 16;
13481
13482 16 guysbuf[ePEAHAT].misc16 = 80;
13483 16 guysbuf[ePEAHAT].misc17 = 16;
13484
13485 16 guysbuf[eGHINI2].misc16 = 120;
13486 16 guysbuf[eGHINI2].misc17 = 10;
13487
13488
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (replay_version_check(20))
13489 {
13490 guysbuf[eGHINI2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13491 guysbuf[eMOLDORM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13492 guysbuf[eKEESETRIB].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13493 guysbuf[eKEESE3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13494 guysbuf[eKEESE2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13495 guysbuf[eKEESE1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13496 guysbuf[eTEK1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13497 guysbuf[eTEK2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13498 guysbuf[ePEAHAT].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13499 guysbuf[eROCK].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13500 guysbuf[eTRAP].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13501 guysbuf[eWALLM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13502 guysbuf[ePOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13503 guysbuf[eMANHAN].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13504 guysbuf[eGLEEOK1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13505 guysbuf[eGLEEOK2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13506 guysbuf[eGLEEOK3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13507 guysbuf[eGLEEOK4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13508 guysbuf[eDIG1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13509 guysbuf[eDIG3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13510 guysbuf[eDIGPUP1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13511 guysbuf[eDIGPUP2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13512 guysbuf[eDIGPUP3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13513 guysbuf[eDIGPUP4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13514 guysbuf[eRAQUAM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13515 guysbuf[eITEMFAIRY].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13516 guysbuf[eFIRE].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13517 guysbuf[eMANHAN2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13518 guysbuf[eTRAP_H].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13519 guysbuf[eTRAP_V].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13520 guysbuf[eTRAP_LR].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13521 guysbuf[eTRAP_UD].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13522 guysbuf[ePATRA1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13523 guysbuf[ePATRA2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13524 guysbuf[ePATRABS].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13525 guysbuf[eBAT].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13526 guysbuf[eGLEEOK1F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13527 guysbuf[eGLEEOK2F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13528 guysbuf[eGLEEOK3F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13529 guysbuf[eGLEEOK4F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13530 guysbuf[eTRIGGER].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13531 guysbuf[ePATRAL2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13532 guysbuf[ePATRAL3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13533 guysbuf[eGOHMA1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13534 guysbuf[eGOHMA2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13535 guysbuf[eGOHMA3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13536 guysbuf[eGOHMA4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13537 guysbuf[eMPOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13538 guysbuf[eWPOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13539 }
13540 16 }
13541
13542
13543
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 114 times.
130 if(guyversion<=2)
13544 {
13545 16 return readherosprites2(f, guyversion==2?0:-1, 0);
13546 }
13547
13548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(guyversion > 3)
13549 {
13550 guydata tempguy;
13551
13552
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<MAXGUYS; i++)
13553 {
13554
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 23) // May 2012 : 512 max enemies
13555 {
13556 if(i >= OLDBETAMAXGUYS)
13557 {
13558 memset(&guysbuf[i], 0, sizeof(guydata));
13559 continue;
13560 }
13561 }
13562
13563 58368 memset(&tempguy, 0, sizeof(guydata));
13564
13565
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.flags),f))
13566 {
13567 return qe_invalid;
13568 }
13569
13570
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.flags2),f))
13571 {
13572 return qe_invalid;
13573 }
13574
13575
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if ( guyversion >= 36 ) //expanded tiles
13576 {
13577
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.tile),f))
13578 {
13579 return qe_invalid;
13580 }
13581 18944 }
13582 else
13583 {
13584
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.tile),f))
13585 {
13586 return qe_invalid;
13587 }
13588 }
13589
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&(tempguy.width),f))
13590 {
13591 return qe_invalid;
13592 }
13593
13594
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&(tempguy.height),f))
13595 {
13596 return qe_invalid;
13597 }
13598
13599
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if ( guyversion >= 36 ) //expanded tiles
13600 {
13601
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.s_tile),f))
13602 {
13603 return qe_invalid;
13604 }
13605 18944 }
13606 else
13607 {
13608
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.s_tile),f))
13609 {
13610 return qe_invalid;
13611 }
13612 }
13613
13614
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&(tempguy.s_width),f))
13615 {
13616 return qe_invalid;
13617 }
13618
13619
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&(tempguy.s_height),f))
13620 {
13621 return qe_invalid;
13622 }
13623
13624
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if ( guyversion >= 36 ) //expanded tiles
13625 {
13626
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.e_tile),f))
13627 {
13628 return qe_invalid;
13629 }
13630 18944 }
13631 else
13632 {
13633
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.e_tile),f))
13634 {
13635 return qe_invalid;
13636 }
13637 }
13638
13639
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&(tempguy.e_width),f))
13640 {
13641 return qe_invalid;
13642 }
13643
13644
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&(tempguy.e_height),f))
13645 {
13646 return qe_invalid;
13647 }
13648
13649
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.hp),f))
13650 {
13651 return qe_invalid;
13652 }
13653
13654
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.family),f))
13655 {
13656 return qe_invalid;
13657 }
13658
13659
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 58368 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
58368 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13660 {
13661 if(get_qr(qr_NEWENEMYTILES))
13662 {
13663 tempguy.s_tile=tempguy.e_tile+120;
13664 tempguy.s_width=tempguy.e_width;
13665 tempguy.s_height=tempguy.e_height;
13666 }
13667 else tempguy.s_tile=860;
13668 }
13669
13670
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.cset),f))
13671 {
13672 return qe_invalid;
13673 }
13674
13675
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.anim),f))
13676 {
13677 return qe_invalid;
13678 }
13679
13680
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.e_anim),f))
13681 {
13682 return qe_invalid;
13683 }
13684
13685
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.frate),f))
13686 {
13687 return qe_invalid;
13688 }
13689
13690
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.e_frate),f))
13691 {
13692 return qe_invalid;
13693 }
13694
13695
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 13) // April 2009
13696 {
13697 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13698 {
13699 tempguy.frate *= 2;
13700 tempguy.e_frate *= 2;
13701 }
13702 }
13703
13704
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 14) // May 1 2009
13705 {
13706 if(tempguy.anim==a2FRMSLOW)
13707 {
13708 tempguy.anim=a2FRM;
13709 tempguy.frate *= 2;
13710 }
13711
13712 if(tempguy.e_anim==a2FRMSLOW)
13713 {
13714 tempguy.e_anim=a2FRM;
13715 tempguy.e_frate *= 2;
13716 }
13717
13718 if(tempguy.anim==aFLIPSLOW)
13719 {
13720 tempguy.anim=aFLIP;
13721 tempguy.frate *= 2;
13722 }
13723
13724 if(tempguy.e_anim==aFLIPSLOW)
13725 {
13726 tempguy.e_anim=aFLIP;
13727 tempguy.e_frate *= 2;
13728 }
13729
13730 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
13731
13732 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
13733
13734 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
13735 {
13736 tempguy.anim=a4FRM4DIR;
13737 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13738 }
13739
13740 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
13741 {
13742 tempguy.e_anim=a4FRM4DIR;
13743 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13744 }
13745 }
13746
13747
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.dp),f))
13748 {
13749 return qe_invalid;
13750 }
13751
13752 //correction for guy fire
13753
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 6)
13754 {
13755 if(i == gFIRE)
13756 tempguy.dp = 2;
13757 }
13758
13759
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.wdp),f))
13760 {
13761 return qe_invalid;
13762 }
13763
13764
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.weapon),f))
13765 {
13766 return qe_invalid;
13767 }
13768
13769 //correction for bosses using triple, "rising" fireballs
13770
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 5)
13771 {
13772 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
13773 i == eGOHMA3 || i == eGOHMA4)
13774 {
13775 if(tempguy.weapon == ewFireball)
13776 tempguy.weapon = ewFireball2;
13777 }
13778 }
13779
13780
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.rate),f))
13781 {
13782 return qe_invalid;
13783 }
13784
13785
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.hrate),f))
13786 {
13787 return qe_invalid;
13788 }
13789
13790
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.step),f))
13791 {
13792 return qe_invalid;
13793 }
13794
13795 // HIGHLY UNORTHODOX UPDATING THING, part 2
13796
3/4
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 56832 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
58368 if(fixpolsvoice && tempguy.family==eePOLSV)
13797 {
13798 tempguy.step /= 2;
13799 }
13800
13801
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.homing),f))
13802 {
13803 return qe_invalid;
13804 }
13805
13806
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.grumble),f))
13807 {
13808 return qe_invalid;
13809 }
13810
13811
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.item_set),f))
13812 {
13813 return qe_invalid;
13814 }
13815
13816
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
13817 {
13818
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc1),f))
13819 {
13820 return qe_invalid;
13821 }
13822
13823
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc2),f))
13824 {
13825 return qe_invalid;
13826 }
13827
13828
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc3),f))
13829 {
13830 return qe_invalid;
13831 }
13832
13833
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc4),f))
13834 {
13835 return qe_invalid;
13836 }
13837
13838
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc5),f))
13839 {
13840 return qe_invalid;
13841 }
13842
13843
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc6),f))
13844 {
13845 return qe_invalid;
13846 }
13847
13848
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc7),f))
13849 {
13850 return qe_invalid;
13851 }
13852
13853
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc8),f))
13854 {
13855 return qe_invalid;
13856 }
13857
13858
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc9),f))
13859 {
13860 return qe_invalid;
13861 }
13862
13863
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc10),f))
13864 {
13865 return qe_invalid;
13866 }
13867 58368 }
13868 else
13869 {
13870 int16_t tempMisc;
13871
13872 if(!p_igetw(&tempMisc,f))
13873 {
13874 return qe_invalid;
13875 }
13876
13877 tempguy.misc1=tempMisc;
13878
13879 if(!p_igetw(&tempMisc,f))
13880 {
13881 return qe_invalid;
13882 }
13883
13884 tempguy.misc2=tempMisc;
13885
13886 if(!p_igetw(&tempMisc,f))
13887 {
13888 return qe_invalid;
13889 }
13890
13891 tempguy.misc3=tempMisc;
13892
13893 if(!p_igetw(&tempMisc,f))
13894 {
13895 return qe_invalid;
13896 }
13897
13898 tempguy.misc4=tempMisc;
13899
13900 if(!p_igetw(&tempMisc,f))
13901 {
13902 return qe_invalid;
13903 }
13904
13905 tempguy.misc5=tempMisc;
13906
13907 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
13908 {
13909 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
13910 tempguy.misc5 = 74;
13911 }
13912
13913 if(!p_igetw(&tempMisc,f))
13914 {
13915 return qe_invalid;
13916 }
13917
13918 tempguy.misc6=tempMisc;
13919
13920 if(!p_igetw(&tempMisc,f))
13921 {
13922 return qe_invalid;
13923 }
13924
13925 tempguy.misc7=tempMisc;
13926
13927 if(!p_igetw(&tempMisc,f))
13928 {
13929 return qe_invalid;
13930 }
13931
13932 tempguy.misc8=tempMisc;
13933
13934 if(!p_igetw(&tempMisc,f))
13935 {
13936 return qe_invalid;
13937 }
13938
13939 tempguy.misc9=tempMisc;
13940
13941 if(!p_igetw(&tempMisc,f))
13942 {
13943 return qe_invalid;
13944 }
13945
13946 tempguy.misc10=tempMisc;
13947 }
13948
13949
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.bgsfx),f))
13950 {
13951 return qe_invalid;
13952 }
13953
13954
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.bosspal),f))
13955 {
13956 return qe_invalid;
13957 }
13958
13959
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.extend),f))
13960 {
13961 return qe_invalid;
13962 }
13963
13964 //! Enemy Defences
13965
13966 //If a 2.50 quest, use only the 2.5 defences.
13967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58368 times.
58368 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
13968 {
13969
2/2
✓ Branch 0 taken 1108992 times.
✓ Branch 1 taken 58368 times.
1167360 for(int32_t j=0; j<edefLAST; j++)
13970 {
13971
1/2
✓ Branch 0 taken 1108992 times.
✗ Branch 1 not taken.
1108992 if(!p_getc(&(tempguy.defense[j]),f))
13972 {
13973 return qe_invalid;
13974 }
13975 1108992 }
13976 //then copy the generic script defence to all the new script defences
13977
13978 58368 }
13979
13980
13981
13982
13983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58368 times.
58368 if(guyversion >= 18)
13984 {
13985
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&(tempguy.hitsfx),f))
13986 {
13987 return qe_invalid;
13988 }
13989
13990
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&(tempguy.deadsfx),f))
13991 {
13992 return qe_invalid;
13993 }
13994 58368 }
13995
13996
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion >= 22)
13997 {
13998
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc11),f))
13999 {
14000 return qe_invalid;
14001 }
14002
14003
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc12),f))
14004 {
14005 return qe_invalid;
14006 }
14007 58368 }
14008 else if(guyversion >= 19)
14009 {
14010 int16_t tempMisc;
14011
14012 if(!p_igetw(&tempMisc,f))
14013 {
14014 return qe_invalid;
14015 }
14016
14017 tempguy.misc11=tempMisc;
14018
14019 if(!p_igetw(&tempMisc,f))
14020 {
14021 return qe_invalid;
14022 }
14023
14024 tempguy.misc12=tempMisc;
14025 }
14026
14027 //If a 2.54 or later quest, use all of the defences.
14028
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion > 24) // Add new guyversion conditional statement
14029 {
14030
2/2
✓ Branch 0 taken 416768 times.
✓ Branch 1 taken 18944 times.
435712 for(int32_t j=edefLAST; j<edefLAST255; j++)
14031 {
14032
1/2
✓ Branch 0 taken 416768 times.
✗ Branch 1 not taken.
416768 if(!p_getc(&(tempguy.defense[j]),f))
14033 {
14034 return qe_invalid;
14035 }
14036 416768 }
14037 18944 }
14038
14039
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14040 {
14041
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14042 {
14043 394240 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14044 394240 }
14045 39424 }
14046
14047 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14048
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion > 25)
14049 {
14050
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.txsz),f))
14051 {
14052 return qe_invalid;
14053 }
14054
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.tysz),f))
14055 {
14056 return qe_invalid;
14057 }
14058
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.hxsz),f))
14059 {
14060 return qe_invalid;
14061 }
14062
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.hysz),f))
14063 {
14064 return qe_invalid;
14065 }
14066
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.hzsz),f))
14067 {
14068 return qe_invalid;
14069 }
14070 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14071
14072 */
14073 18944 }
14074 //More Enemy Editor vars for 2.60
14075
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion > 26)
14076 {
14077
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.hxofs),f))
14078 {
14079 return qe_invalid;
14080 }
14081
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.hyofs),f))
14082 {
14083 return qe_invalid;
14084 }
14085
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.xofs),f))
14086 {
14087 return qe_invalid;
14088 }
14089
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.yofs),f))
14090 {
14091 return qe_invalid;
14092 }
14093
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.zofs),f))
14094 {
14095 return qe_invalid;
14096 }
14097 18944 }
14098
14099
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14100 {
14101 39424 tempguy.wpnsprite = 0;
14102 39424 }
14103
14104
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion > 27)
14105 {
14106
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.wpnsprite),f))
14107 {
14108 return qe_invalid;
14109 }
14110 18944 }
14111
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14112 {
14113 39424 tempguy.SIZEflags = 0;
14114 39424 }
14115
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion > 28)
14116 {
14117
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.SIZEflags),f))
14118 {
14119 return qe_invalid;
14120 }
14121
14122 18944 }
14123
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14124 {
14125 39424 tempguy.frozentile = 0;
14126 39424 tempguy.frozencset = 0;
14127 39424 tempguy.frozenclock = 0;
14128
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14129 39424 }
14130
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion >= 30)
14131 {
14132
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.frozentile),f))
14133 {
14134 return qe_invalid;
14135 }
14136
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.frozencset),f))
14137 {
14138 return qe_invalid;
14139 }
14140
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.frozenclock),f))
14141 {
14142 return qe_invalid;
14143 }
14144
2/2
✓ Branch 0 taken 189440 times.
✓ Branch 1 taken 18944 times.
208384 for ( int32_t q = 0; q < 10; q++ ) {
14145
1/2
✓ Branch 0 taken 189440 times.
✗ Branch 1 not taken.
189440 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14146 {
14147 return qe_invalid;
14148 }
14149 189440 }
14150
14151 18944 }
14152
14153
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion >= 34)
14154 {
14155
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetw(&(tempguy.firesfx),f))
14156 {
14157 return qe_invalid;
14158 }
14159
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc16),f))
14160 {
14161 return qe_invalid;
14162 }
14163
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc17),f))
14164 {
14165 return qe_invalid;
14166 }
14167
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc18),f))
14168 {
14169 return qe_invalid;
14170 }
14171
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc19),f))
14172 {
14173 return qe_invalid;
14174 }
14175
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc20),f))
14176 {
14177 return qe_invalid;
14178 }
14179
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc21),f))
14180 {
14181 return qe_invalid;
14182 }
14183
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc22),f))
14184 {
14185 return qe_invalid;
14186 }
14187
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc23),f))
14188 {
14189 return qe_invalid;
14190 }
14191
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc24),f))
14192 {
14193 return qe_invalid;
14194 }
14195
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc25),f))
14196 {
14197 return qe_invalid;
14198 }
14199
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc26),f))
14200 {
14201 return qe_invalid;
14202 }
14203
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc27),f))
14204 {
14205 return qe_invalid;
14206 }
14207
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc28),f))
14208 {
14209 return qe_invalid;
14210 }
14211
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc29),f))
14212 {
14213 return qe_invalid;
14214 }
14215
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc30),f))
14216 {
14217 return qe_invalid;
14218 }
14219
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc31),f))
14220 {
14221 return qe_invalid;
14222 }
14223
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc32),f))
14224 {
14225 return qe_invalid;
14226 }
14227
14228
2/2
✓ Branch 0 taken 606208 times.
✓ Branch 1 taken 18944 times.
625152 for ( int32_t q = 0; q < 32; q++ ) {
14229
1/2
✓ Branch 0 taken 606208 times.
✗ Branch 1 not taken.
606208 if(!p_igetl(&(tempguy.movement[q]),f))
14230 {
14231 return qe_invalid;
14232 }
14233 606208 }
14234
2/2
✓ Branch 0 taken 606208 times.
✓ Branch 1 taken 18944 times.
625152 for ( int32_t q = 0; q < 32; q++ ) {
14235
1/2
✓ Branch 0 taken 606208 times.
✗ Branch 1 not taken.
606208 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14236 {
14237 return qe_invalid;
14238 }
14239 606208 }
14240
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetw(&(tempguy.script),f))
14241 {
14242 return qe_invalid;
14243 }
14244 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14245
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for ( int32_t q = 0; q < 8; q++ )
14246 {
14247
1/2
✓ Branch 0 taken 151552 times.
✗ Branch 1 not taken.
151552 if(!p_igetl(&(tempguy.initD[q]),f))
14248 {
14249 return qe_invalid;
14250 }
14251 151552 }
14252
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 18944 times.
56832 for ( int32_t q = 0; q < 2; q++ )
14253 {
14254
1/2
✓ Branch 0 taken 37888 times.
✗ Branch 1 not taken.
37888 if(!p_igetl(&(tempguy.initA[q]),f))
14255 {
14256 return qe_invalid;
14257 }
14258 37888 }
14259
14260 18944 }
14261
14262
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion >= 37)
14263 {
14264
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.editorflags),f))
14265 {
14266 return qe_invalid;
14267 }
14268 18944 }
14269
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14270
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion >= 38)
14271 {
14272
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc13),f))
14273 {
14274 return qe_invalid;
14275 }
14276
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc14),f))
14277 {
14278 return qe_invalid;
14279 }
14280
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc15),f))
14281 {
14282 return qe_invalid;
14283 }
14284
14285 18944 }
14286
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if ( guyversion < 38 )
14287 {
14288 39424 tempguy.misc13 = 0;
14289 39424 tempguy.misc14 = 0;
14290 39424 tempguy.misc15 = 0;
14291 39424 }
14292
14293
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if ( guyversion >= 39 )
14294 {
14295
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for ( int32_t q = 0; q < 8; q++ )
14296 {
14297
2/2
✓ Branch 0 taken 9850880 times.
✓ Branch 1 taken 151552 times.
10002432 for ( int32_t w = 0; w < 65; w++ )
14298 {
14299
1/2
✓ Branch 0 taken 9850880 times.
✗ Branch 1 not taken.
9850880 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14300 {
14301 return qe_invalid;
14302 }
14303 9850880 }
14304
2/2
✓ Branch 0 taken 9850880 times.
✓ Branch 1 taken 151552 times.
10002432 for ( int32_t w = 0; w < 65; w++ )
14305 {
14306
1/2
✓ Branch 0 taken 9850880 times.
✗ Branch 1 not taken.
9850880 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14307 {
14308 return qe_invalid;
14309 }
14310 9850880 }
14311 151552 }
14312
14313
14314 18944 }
14315
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if ( guyversion < 39 ) //apply old InitD strings to both
14316 {
14317
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ )
14318 {
14319 315392 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14320 315392 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14321 315392 }
14322 39424 }
14323
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if ( guyversion >= 40 )
14324 {
14325
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetw(&(tempguy.weaponscript),f))
14326 {
14327 return qe_invalid;
14328 }
14329 18944 }
14330
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if ( guyversion < 40 )
14331 {
14332 39424 tempguy.weaponscript = 0;
14333 39424 }
14334 //eweapon script InitD
14335
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if ( guyversion >= 41 )
14336 {
14337
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for ( int32_t q = 0; q < 8; q++ )
14338 {
14339
1/2
✓ Branch 0 taken 151552 times.
✗ Branch 1 not taken.
151552 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14340 {
14341 return qe_invalid;
14342 }
14343 151552 }
14344
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if ( guy_cversion < 4 )
14345 {
14346 if ( tempguy.family == eeKEESE )
14347 {
14348
14349 if ( !tempguy.misc1 )
14350 {
14351 tempguy.misc16 = 120;
14352 tempguy.misc17 = 16;
14353
14354 }
14355 }
14356 if ( tempguy.family == eePEAHAT )
14357 {
14358 tempguy.misc16 = 80;
14359 tempguy.misc17 = 16;
14360 }
14361
14362 if ( tempguy.family == eeGHINI )
14363 {
14364 tempguy.misc16 = 120;
14365 tempguy.misc17 = 10;
14366 }
14367
14368 }
14369 18944 }
14370
14371
14372
14373 //default weapon sprites (quest version < 2.54)
14374 //port over old defaults -Z
14375
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion < 32)
14376 {
14377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.wpnsprite <= 0 )
14378 {
14379
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14380 {
14381 case wNone:
14382 32842 tempguy.wpnsprite = 0; break;
14383
14384 case wSword:
14385 case wBeam:
14386 case wBrang:
14387 case wBomb:
14388 case wSBomb:
14389 case wLitBomb:
14390 case wLitSBomb:
14391 case wArrow:
14392 case wFire:
14393 case wWhistle:
14394 case wBait:
14395 case wWand:
14396 case wMagic:
14397 case wCatching:
14398 case wWind:
14399 case wRefMagic:
14400 case wRefFireball:
14401 case wRefRock:
14402 case wHammer:
14403 case wHookshot:
14404 case wHSHandle:
14405 case wHSChain:
14406 case wSSparkle:
14407 case wFSparkle:
14408 case wSmack:
14409 case wPhantom:
14410 case wCByrna:
14411 case wRefBeam:
14412 case wStomp:
14413 case lwMax:
14414 case wScript1:
14415 case wScript2:
14416 case wScript3:
14417 case wScript4:
14418 case wScript5:
14419 case wScript6:
14420 case wScript7:
14421 case wScript8:
14422 case wScript9:
14423 case wScript10:
14424 case wIce:
14425 //Cannot use any of these weapons yet.
14426 tempguy.wpnsprite = -1;
14427 break;
14428
14429 case wEnemyWeapons:
14430 1303 case ewFireball: tempguy.wpnsprite = 17; break;
14431
14432 302 case ewArrow: tempguy.wpnsprite = 19; break;
14433 314 case ewBrang: tempguy.wpnsprite = 4; break;
14434 931 case ewSword: tempguy.wpnsprite = 20; break;
14435 493 case ewRock: tempguy.wpnsprite = 18; break;
14436 912 case ewMagic: tempguy.wpnsprite = 21; break;
14437 80 case ewBomb: tempguy.wpnsprite = 78; break;
14438 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14439 137 case ewLitBomb: tempguy.wpnsprite = 76; break;
14440 19 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14441 363 case ewFireTrail: tempguy.wpnsprite = 80; break;
14442 759 case ewFlame: tempguy.wpnsprite = 35; break;
14443 106 case ewWind: tempguy.wpnsprite = 36; break;
14444 80 case ewFlame2: tempguy.wpnsprite = 81; break;
14445 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14446 case ewIce: tempguy.wpnsprite = 83; break;
14447 765 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14448
14449
14450 default: break; //No assign.
14451 }
14452 39424 }
14453 39424 }
14454
14455 //default weapon fire sound (quest version < 2.54)
14456 //port over old defaults and zero new data. -Z
14457
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion < 34)
14458 {
14459
2/2
✓ Branch 0 taken 1261568 times.
✓ Branch 1 taken 39424 times.
1300992 for ( int32_t q = 0; q < 32; q++ )
14460 {
14461 1261568 tempguy.movement[q] = 0;
14462 1261568 tempguy.new_weapon[q] = 0;
14463
14464 1261568 }
14465
14466 //NPC Script attributes.
14467 39424 tempguy.script = 0; //No scripted enemies existed. -Z
14468
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14469
2/2
✓ Branch 0 taken 78848 times.
✓ Branch 1 taken 39424 times.
118272 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14470
14471 39424 tempguy.misc16 = 0;
14472 39424 tempguy.misc17 = 0;
14473 39424 tempguy.misc18 = 0;
14474 39424 tempguy.misc19 = 0;
14475 39424 tempguy.misc20 = 0;
14476 39424 tempguy.misc21 = 0;
14477 39424 tempguy.misc22 = 0;
14478 39424 tempguy.misc23 = 0;
14479 39424 tempguy.misc24 = 0;
14480 39424 tempguy.misc25 = 0;
14481 39424 tempguy.misc26 = 0;
14482 39424 tempguy.misc27 = 0;
14483 39424 tempguy.misc28 = 0;
14484 39424 tempguy.misc29 = 0;
14485 39424 tempguy.misc30 = 0;
14486 39424 tempguy.misc31 = 0;
14487 39424 tempguy.misc32 = 0;
14488
14489 //old default sounds
14490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.firesfx <= 0 )
14491 {
14492
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14493 {
14494 case wNone:
14495 32842 tempguy.firesfx = 0; break;
14496
14497 case wSword:
14498 case wBeam:
14499 case wBrang:
14500 case wBomb:
14501 case wSBomb:
14502 case wLitBomb:
14503 case wLitSBomb:
14504 case wArrow:
14505 case wFire:
14506 case wWhistle:
14507 case wBait:
14508 case wWand:
14509 case wMagic:
14510 case wCatching:
14511 case wWind:
14512 case wRefMagic:
14513 case wRefFireball:
14514 case wRefRock:
14515 case wHammer:
14516 case wHookshot:
14517 case wHSHandle:
14518 case wHSChain:
14519 case wSSparkle:
14520 case wFSparkle:
14521 case wSmack:
14522 case wPhantom:
14523 case wCByrna:
14524 case wRefBeam:
14525 case wStomp:
14526 case lwMax:
14527 case wScript1:
14528 case wScript2:
14529 case wScript3:
14530 case wScript4:
14531 case wScript5:
14532 case wScript6:
14533 case wScript7:
14534 case wScript8:
14535 case wScript9:
14536 case wScript10:
14537 case wIce:
14538 //Cannot use any of these weapons yet.
14539 tempguy.firesfx = -1;
14540 break;
14541
14542 case wEnemyWeapons:
14543 1303 case ewFireball: tempguy.firesfx = 40; break;
14544
14545 302 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14546 314 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14547 931 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14548 493 case ewRock: tempguy.firesfx = 51; break;
14549 912 case ewMagic: tempguy.firesfx = 32; break;
14550 80 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14551 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14552 137 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14553 19 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14554 363 case ewFireTrail: tempguy.firesfx = 13; break;
14555 759 case ewFlame: tempguy.firesfx = 13; break;
14556 106 case ewWind: tempguy.firesfx = 32; break;
14557 80 case ewFlame2: tempguy.firesfx = 13; break;
14558 case ewFlame2Trail: tempguy.firesfx = 13; break;
14559 case ewIce: tempguy.firesfx = 44; break;
14560 765 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14561
14562 //what about special attacks (e.g. summoning == 56)
14563 default: break; //No assign.
14564 }
14565 39424 }
14566 39424 }
14567
14568 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14569
4/6
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
✓ Branch 2 taken 18944 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18944 times.
58368 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14570 {
14571
2/2
✓ Branch 0 taken 3549 times.
✓ Branch 1 taken 35875 times.
39424 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14572 39424 }
14573 //Keese and bat halt rates.
14574
3/4
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39424 times.
58368 if ( guyversion < 42 && guy_cversion < 4 )
14575 {
14576
14577
2/2
✓ Branch 0 taken 38895 times.
✓ Branch 1 taken 529 times.
39424 if ( tempguy.family == eeKEESE )
14578 {
14579
14580
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 326 times.
529 if ( !tempguy.misc1 )
14581 {
14582 326 tempguy.misc16 = 120;
14583 326 tempguy.misc17 = 16;
14584
14585 326 }
14586 529 }
14587
2/2
✓ Branch 0 taken 39257 times.
✓ Branch 1 taken 167 times.
39424 if ( tempguy.family == eePEAHAT )
14588 {
14589 167 tempguy.misc16 = 80;
14590 167 tempguy.misc17 = 16;
14591 167 }
14592
2/2
✓ Branch 0 taken 39347 times.
✓ Branch 1 taken 77 times.
39424 if ( tempguy.family == eeGHINI )
14593 {
14594 77 tempguy.misc16 = 120;
14595 77 tempguy.misc17 = 10;
14596 77 }
14597
14598
14599 39424 }
14600
14601
14602 //miscellaneous other corrections
14603 //fix the mirror wizzrobe -DD
14604
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 7)
14605 {
14606 if(i == eMWIZ)
14607 {
14608 tempguy.misc2 = 0;
14609 tempguy.misc4 = 1;
14610 }
14611 }
14612
14613
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 8)
14614 {
14615 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14616 {
14617 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14618 tempguy.misc5 = 4; //neck length in segments
14619 tempguy.misc6 = 8; //neck offset from first body tile
14620 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14621 tempguy.misc8 = 168; //head offset from first body tile
14622 tempguy.misc9 = 228; //flying head offset from first body tile
14623
14624 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14625 {
14626 tempguy.misc6 += 10; //neck offset from first body tile
14627 tempguy.misc8 -= 12; //head offset from first body tile
14628 }
14629 }
14630 }
14631
14632
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14633 {
14634 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14635 tempguy.bosspal = spDIG;
14636 }
14637
14638
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 11) // December 2007 - Spinning Tile fix
14639 {
14640 if(tempguy.family==eeSPINTILE)
14641 {
14642 tempguy.flags |= guy_superman;
14643 tempguy.item_set = 0; // Don't drop items
14644 tempguy.step = 300;
14645 }
14646 }
14647
14648
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14649 {
14650 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14651 {
14652 if(tempguy.family==eeROPE)
14653 {
14654 tempguy.flags2 &= ~guy_flashing;
14655 }
14656 }
14657
14658 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14659 {
14660 if(tempguy.family==eeBUBBLE)
14661 {
14662 tempguy.flags2 &= ~guy_flashing;
14663 }
14664 }
14665
14666 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14667 {
14668 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14669 {
14670 tempguy.flags2 |= guy_blinking;
14671 }
14672
14673 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14674 {
14675 tempguy.flags2 |= guy_transparent;
14676 }
14677 }
14678 }
14679
14680
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14681 {
14682 if(i==gFIRE)
14683 {
14684 tempguy.e_anim = aFLIP;
14685 tempguy.e_frate = 24;
14686 }
14687
14688 if(i==gFAIRY)
14689 {
14690 tempguy.e_anim = a2FRM;
14691 tempguy.e_frate = 16;
14692 }
14693 }
14694
14695
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14696 {
14697 if(i==0) Z_message("Updating guys to version 16...\n");
14698
14699 update_guy_1(&tempguy);
14700
14701 if(i==eMPOLSV)
14702 {
14703 tempguy.defense[edefARROW] = edCHINK;
14704 tempguy.defense[edefMAGIC] = ed1HKO;
14705 tempguy.defense[edefREFMAGIC] = ed1HKO;
14706 }
14707 }
14708
14709
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 17) // December 2009
14710 {
14711 if(tempguy.family==eePROJECTILE)
14712 {
14713 tempguy.misc1 = 0;
14714 }
14715 }
14716
14717
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 18) // January 2010
14718 {
14719 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14720 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14721
14722 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14723 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
14724
14725 if(tempguy.family == eeAQUA)
14726 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14727 else if(tempguy.family == eeMANHAN)
14728 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14729 else if(tempguy.family==eePATRA)
14730 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14731 else if(tempguy.family==eeGHOMA)
14732 {
14733 for(int32_t j=0; j<edefLAST; j++)
14734 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14735
14736 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
14737
14738 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14739
14740 tempguy.misc1--;
14741 }
14742 else if(tempguy.family == eeGLEEOK)
14743 {
14744 for(int32_t j=0; j<edefLAST; j++)
14745 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14746
14747 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14748 }
14749 else if(tempguy.family == eeARMOS)
14750 {
14751 tempguy.family=eeWALK;
14752 tempguy.hrate = 0;
14753 tempguy.misc10 = tempguy.misc1;
14754 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
14755 tempguy.misc9 = e9tARMOS;
14756 }
14757 else if(tempguy.family == eeGHINI && !tempguy.misc1)
14758 {
14759 tempguy.family=eeWALK;
14760 tempguy.hrate = 0;
14761 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
14762 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
14763 }
14764
14765 // Spawn animation flags
14766 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
14767 tempguy.flags |= guy_fadeflicker;
14768 else
14769 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
14770 }
14771
14772
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 20) // April 2010
14773 {
14774 if(tempguy.family == eeTRAP)
14775 {
14776 tempguy.misc2 = tempguy.misc10;
14777
14778 if(tempguy.misc10>=1)
14779 {
14780 tempguy.misc1++;
14781 }
14782
14783 tempguy.misc10 = 0;
14784 }
14785
14786 // Bomb Blast fix
14787 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
14788 tempguy.weapon = ewLitBomb;
14789 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
14790 tempguy.weapon = ewLitSBomb;
14791 }
14792
14793
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 21) // September 2011
14794 {
14795 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
14796 {
14797 if(tempguy.family == eeKEESETRIB)
14798 {
14799 tempguy.family = eeKEESE;
14800 tempguy.misc2 = e2tKEESETRIB;
14801 tempguy.misc1 = 0;
14802 }
14803
14804 tempguy.rate = 2;
14805 tempguy.hrate = 8;
14806 tempguy.homing = 0;
14807 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
14808 }
14809 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
14810 {
14811 if(tempguy.family == eePEAHAT)
14812 {
14813 tempguy.rate = 4;
14814 tempguy.step = 62;
14815 }
14816 else
14817 tempguy.step = 25;
14818
14819 tempguy.hrate = 8;
14820 tempguy.homing = 0;
14821 }
14822 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
14823 {
14824 if(tempguy.family == eeMANHAN)
14825 tempguy.step=50;
14826
14827 tempguy.hrate = 16;
14828 tempguy.homing = 0;
14829 }
14830 else if(tempguy.family == eeGLEEOK)
14831 {
14832 tempguy.rate = 2;
14833 tempguy.homing = 0;
14834 tempguy.hrate = 9;
14835 tempguy.step=89;
14836 }
14837 else if(tempguy.family == eeGHINI)
14838 {
14839 tempguy.rate = 4;
14840 tempguy.hrate = 12;
14841 tempguy.step=62;
14842 tempguy.homing = 0;
14843 }
14844
14845 // Bigdig random rate fix
14846 if(tempguy.family==eeDIG && tempguy.misc10==1)
14847 {
14848 tempguy.rate = 2;
14849 }
14850 }
14851
14852
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 24) // November 2012
14853 {
14854 if(tempguy.family==eeLANM)
14855 tempguy.misc3 = 1;
14856 else if(tempguy.family==eeMOLD)
14857 tempguy.misc2 = 0;
14858 }
14859
14860
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
14861 {
14862
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 38764 times.
39424 if(tempguy.family!=eeDIG)
14863 {
14864 38764 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
14865 38764 }
14866
14867 39424 }
14868 // does not seem to solve the issue!
14869
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if ( Header->zelda_version <= 0x210 )
14870 {
14871 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
14872 if ( tempguy.family == eeDONGO )
14873 {
14874 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14875 }
14876 }
14877
14878
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion >= 42)
14879 {
14880
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 1024 times.
18944 if(guyversion >= 47)
14881 {
14882
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.moveflags),f))
14883 {
14884 return qe_invalid;
14885 }
14886 17920 }
14887 else
14888 {
14889 byte fl;
14890
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f))
14891 {
14892 return qe_invalid;
14893 }
14894 1024 tempguy.moveflags = fl;
14895 }
14896 18944 }
14897 else
14898 {
14899
7/8
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 30899 times.
✓ Branch 2 taken 1202 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 518 times.
✓ Branch 5 taken 278 times.
✓ Branch 6 taken 241 times.
✓ Branch 7 taken 5840 times.
39424 switch(tempguy.family)
14900 {
14901 //No gravity; floats over pits
14902 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14903 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14904 //Special (bosses, etc)
14905 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14906 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14907 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14908 30899 tempguy.moveflags = FLAG_CAN_PITWALK;
14909 30899 break;
14910 //No gravity, but falls in pits
14911 case eeLEV:
14912 518 tempguy.moveflags = FLAG_CAN_PITFALL;
14913 518 break;
14914 //Bosses that respect pits
14915 case eeDONGO:
14916 278 tempguy.moveflags = FLAG_OBEYS_GRAV;
14917 278 break;
14918 case eeLANM:
14919 241 tempguy.moveflags = 0;
14920 241 break;
14921 //Gravity, floats over pits
14922 case eeWIZZ: case eeWALLM: case eeGHINI:
14923 1202 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
14924 1202 break;
14925 //Gravity and falls in pits
14926 case eeWALK:
14927
4/4
✓ Branch 0 taken 5519 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 5239 times.
5840 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
14928 601 break;
14929 [[fallthrough]];
14930 case eeOTHER:
14931 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
14932 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
14933 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
14934 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
14935 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
14936 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
14937 5685 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
14938 5685 }
14939 }
14940
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion < 43)
14941 {
14942
2/2
✓ Branch 0 taken 32101 times.
✓ Branch 1 taken 7323 times.
39424 switch(tempguy.family)
14943 {
14944 //No gravity; floats over pits
14945 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14946 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14947 //Special (bosses, etc)
14948 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14949 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14950 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14951 case eeWIZZ: case eeWALLM: case eeGHINI:
14952 //Gravity, floats over pits
14953 32101 tempguy.moveflags |= FLAG_CAN_WATERWALK;
14954 32101 tempguy.moveflags |= FLAG_CAN_PITWALK;
14955 32101 break;
14956 }
14957 39424 }
14958
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if (guyversion < 44)
14959 {
14960
2/2
✓ Branch 0 taken 39054 times.
✓ Branch 1 taken 370 times.
39424 if ( tempguy.family == eeGHOMA )
14961 {
14962 370 tempguy.flags |= guy_fadeinstant;
14963 370 }
14964 39424 }
14965
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if (guyversion > 44)
14966 {
14967
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&(tempguy.spr_shadow),f))
14968 {
14969 return qe_invalid;
14970 }
14971
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&(tempguy.spr_death),f))
14972 {
14973 return qe_invalid;
14974 }
14975
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&(tempguy.spr_spawn),f))
14976 {
14977 return qe_invalid;
14978 }
14979 18944 }
14980 else
14981 {
14982
2/2
✓ Branch 0 taken 39271 times.
✓ Branch 1 taken 153 times.
39424 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
14983 39424 tempguy.spr_death = iwDeath;
14984 39424 tempguy.spr_spawn = iwSpawn;
14985 }
14986
14987
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion < 46)
14988 {
14989
4/4
✓ Branch 0 taken 5840 times.
✓ Branch 1 taken 33584 times.
✓ Branch 2 taken 5519 times.
✓ Branch 3 taken 321 times.
39424 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
14990 {
14991 321 tempguy.moveflags |= FLAG_CAN_WATERWALK;
14992 321 }
14993 39424 }
14994
14995 58368 guysbuf[i] = tempguy;
14996 58368 }
14997 114 }
14998
14999 114 return 0;
15000 130 }
15001
15002 void update_guy_1(guydata *tempguy) // November 2009
15003 {
15004 bool doesntcount = false;
15005 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15006
15007 switch(tempguy->family)
15008 {
15009 case 1: //eeWALK
15010 switch(tempguy->misc10)
15011 {
15012 case 0: //Stalfos
15013 if(tempguy->misc1==1) // Fires four projectiles at once
15014 tempguy->misc1=4;
15015
15016 break;
15017
15018 case 1: //Darknut
15019 goto darknuts;
15020 break;
15021 }
15022
15023 tempguy->misc10 = 0;
15024 break;
15025
15026 case 2: //eeSHOOT
15027 tempguy->family = eeWALK;
15028
15029 switch(tempguy->misc10)
15030 {
15031 case 0: //Octorok
15032 if(tempguy->misc1==1||tempguy->misc1==2)
15033 {
15034 tempguy->misc1=e1tFIREOCTO;
15035 tempguy->misc2=e2tFIREOCTO;
15036 }
15037 else tempguy->misc1 = 0;
15038
15039 tempguy->misc6=tempguy->misc4;
15040 tempguy->misc4=tempguy->misc3;
15041 tempguy->misc3=0;
15042 break;
15043
15044 case 1: // Moblin
15045 tempguy->misc1 = 0;
15046 break;
15047
15048 case 2: //Lynel
15049 tempguy->misc6=tempguy->misc1+1;
15050 tempguy->misc1=0;
15051 break;
15052
15053 case 3: //Stalfos 2
15054 if(tempguy->misc1==1) // Fires four projectiles at once
15055 tempguy->misc1=e1t4SHOTS;
15056 else tempguy->misc1 = 0;
15057
15058 break;
15059
15060 case 4: //Darknut 5
15061 darknuts:
15062 tempguy->defense[edefFIRE] = edIGNORE;
15063 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15064 tempguy->defense[edefHOOKSHOT] = 0;
15065 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15066 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15067
15068 if(tempguy->misc1==1)
15069 tempguy->misc1=2;
15070 else if(tempguy->misc1==2)
15071 {
15072 tempguy->misc4=tempguy->misc3;
15073 tempguy->misc3=tempguy->misc2;
15074 tempguy->misc2=e2tSPLIT;
15075 tempguy->misc1 = 0;
15076 }
15077 else tempguy->misc1 = 0;
15078
15079 tempguy->flags |= inv_front;
15080
15081 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15082 tempguy->flags |= guy_bkshield;
15083
15084 break;
15085 }
15086
15087 tempguy->misc10 = 0;
15088 break;
15089
15090 /*
15091 case 9: //eeARMOS
15092 tempguy->family = eeWALK;
15093 break;
15094 */
15095 case 11: //eeGEL
15096 case 33: //eeGELTRIB
15097 if(tempguy->family==33)
15098 {
15099 tempguy->misc4 = 1;
15100
15101 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15102 tempguy->misc3 = tempguy->misc2;
15103
15104 tempguy->misc2 = e2tTRIBBLE;
15105 }
15106 else
15107 {
15108 tempguy->misc4 = 0;
15109 tempguy->misc3 = 0;
15110 tempguy->misc2 = 0;
15111 }
15112
15113 tempguy->family = eeWALK;
15114
15115 if(tempguy->misc1)
15116 {
15117 tempguy->misc1=1;
15118 tempguy->weapon = ewFireTrail;
15119 }
15120
15121 break;
15122
15123 case 34: //eeZOLTRIB
15124 case 12: //eeZOL
15125 tempguy->misc4=tempguy->misc3;
15126 tempguy->misc3=tempguy->misc2;
15127 tempguy->family = eeWALK;
15128 tempguy->misc2=e2tSPLITHIT;
15129
15130 if(tempguy->misc1)
15131 {
15132 tempguy->misc1=1;
15133 tempguy->weapon = ewFireTrail;
15134 }
15135
15136 break;
15137
15138 case 13: //eeROPE
15139 tempguy->family = eeWALK;
15140 tempguy->misc9 = e9tROPE;
15141
15142 if(tempguy->misc1)
15143 {
15144 tempguy->misc4 = tempguy->misc3;
15145 tempguy->misc3 = tempguy->misc2;
15146 tempguy->misc2 = e2tBOMBCHU;
15147 }
15148
15149 tempguy->misc1 = 0;
15150 break;
15151
15152 case 14: //eeGORIYA
15153 tempguy->family = eeWALK;
15154
15155 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15156
15157 break;
15158
15159 case 17: //eeBUBBLE
15160 tempguy->family = eeWALK;
15161 tempguy->misc8 = tempguy->misc2;
15162 tempguy->misc7 = tempguy->misc1 + 1;
15163 tempguy->misc1 = tempguy->misc2 = 0;
15164
15165 //fallthrogh
15166 case eeTRAP:
15167 case eeROCK:
15168 doesntcount = true;
15169 break;
15170
15171 case 35: //eeVIRETRIB
15172 case 18: //eeVIRE
15173 tempguy->family = eeWALK;
15174 tempguy->misc4=tempguy->misc3;
15175 tempguy->misc3=tempguy->misc2;
15176 tempguy->misc2=e2tSPLITHIT;
15177 tempguy->misc9=e9tVIRE;
15178 break;
15179
15180 case 19: //eeLIKE
15181 tempguy->family = eeWALK;
15182 tempguy->misc7 = e7tEATITEMS;
15183 tempguy->misc8=95;
15184 break;
15185
15186 case 20: //eePOLSV
15187 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15188 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15189 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15190 tempguy->defense[edefARROW] = ed1HKO;
15191 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15192 tempguy->family = eeWALK;
15193 tempguy->misc9 = e9tPOLSVOICE;
15194 tempguy->rate = 4;
15195 tempguy->homing = 32;
15196 tempguy->hrate = 10;
15197 tempguy->grumble = 0;
15198 break;
15199
15200 case eeWIZZ:
15201 if(tempguy->misc4)
15202 {
15203 for(int32_t i=0; i < edefLAST; i++)
15204 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15205 }
15206 else
15207 {
15208 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15209 tempguy->defense[edefMAGIC] = edCHINK;
15210 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15211 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15212 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15213 }
15214
15215 break;
15216
15217 case eePEAHAT:
15218 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15219
15220 if(!(tempguy->flags & guy_bhit))
15221 tempguy->defense[edefBRANG] = edSTUNONLY;
15222
15223 break;
15224
15225 case eeLEV:
15226 tempguy->defense[edefSTOMP] = edCHINK;
15227 break;
15228 }
15229
15230 // Old flags
15231 if(tempguy->flags & guy_superman)
15232 {
15233 for(int32_t i = 0; i < edefLAST; i++)
15234 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15235 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15236 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15237 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15238 }
15239
15240 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15241
15242 if(doesntcount)
15243 tempguy->flags |= (guy_doesntcount);
15244 }
15245
15246
15247 247176 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15248 {
15249 byte tempbyte, padding;
15250 int32_t extras, secretcombos;
15251 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->valid),f))
15253 {
15254 return qe_invalid;
15255 }
15256
15257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->guy),f))
15258 return qe_invalid;
15259 247176 temp_mapscr->guytile = -1; //signal to use default guy values
15260
2/2
✓ Branch 0 taken 246700 times.
✓ Branch 1 taken 476 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15261
4/4
✓ Branch 0 taken 476 times.
✓ Branch 1 taken 246700 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 453 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15262
15263
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15264 {
15265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15266 {
15267 return qe_invalid;
15268 }
15269
15270 6864 temp_mapscr->str=tempbyte;
15271 6864 }
15272 else
15273 {
15274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->str),f))
15275 {
15276 return qe_invalid;
15277 }
15278 }
15279
15280
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->room),f))
15281 {
15282 return qe_invalid;
15283 }
15284
15285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->item),f))
15286 {
15287 return qe_invalid;
15288 }
15289
15290
3/6
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153408 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15291 {
15292 93768 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15293 93768 }
15294 else
15295 {
15296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->hasitem),f))
15297 return qe_invalid;
15298 }
15299
15300
2/4
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version < 0x192)||
15301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15302 {
15303
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15304 {
15305 return qe_invalid;
15306 }
15307 6864 }
15308
15309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15310 {
15311 return qe_invalid;
15312 }
15313
15314
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15315 {
15316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15317 {
15318 return qe_invalid;
15319 }
15320 6864 }
15321
15322
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15323 {
15324
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15325 {
15326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15327 {
15328 return qe_invalid;
15329 }
15330 460224 }
15331 153408 }
15332 else
15333 {
15334 93768 temp_mapscr->tilewarptype[1]=0;
15335 93768 temp_mapscr->tilewarptype[2]=0;
15336 93768 temp_mapscr->tilewarptype[3]=0;
15337 }
15338
15339
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15340 {
15341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15342 {
15343 return qe_invalid;
15344 }
15345 240312 }
15346
15347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15348 {
15349 return qe_invalid;
15350 }
15351
15352 247176 temp_mapscr->warpreturnx[1]=0;
15353 247176 temp_mapscr->warpreturnx[2]=0;
15354 247176 temp_mapscr->warpreturnx[3]=0;
15355
15356
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15357 {
15358
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15359 {
15360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15361 {
15362 return qe_invalid;
15363 }
15364 460224 }
15365 153408 }
15366
15367
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15368 {
15369 return qe_invalid;
15370 }
15371
15372 247176 temp_mapscr->warpreturny[1]=0;
15373 247176 temp_mapscr->warpreturny[2]=0;
15374 247176 temp_mapscr->warpreturny[3]=0;
15375
15376
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15377 {
15378
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15379 {
15380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15381 {
15382 return qe_invalid;
15383 }
15384 460224 }
15385
15386
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(version>=18)
15387 {
15388
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15389 {
15390 return qe_invalid;
15391 }
15392 153408 }
15393 else
15394 {
15395 byte temp;
15396
15397 if(!p_getc(&temp,f))
15398 {
15399 return qe_invalid;
15400 }
15401
15402 temp_mapscr->warpreturnc=temp<<8|temp;
15403 }
15404 153408 }
15405
15406
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->stairx),f))
15407
15408 {
15409 return qe_invalid;
15410 }
15411
15412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->stairy),f))
15413 {
15414 return qe_invalid;
15415 }
15416
15417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemx),f))
15418 {
15419 return qe_invalid;
15420 }
15421
15422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemy),f))
15423 {
15424 return qe_invalid;
15425 }
15426
15427
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version > 15) // February 2009
15428 {
15429
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->color),f))
15430 {
15431 return qe_invalid;
15432 }
15433 153408 }
15434 else
15435 {
15436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93768 times.
93768 if(!p_getc(& tempbyte,f))
15437 {
15438 return qe_invalid;
15439 }
15440
15441 93768 temp_mapscr->color = (word) tempbyte;
15442 }
15443
15444
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->enemyflags),f))
15445 {
15446 return qe_invalid;
15447 }
15448
15449
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15450 {
15451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->door[k]),f))
15452 {
15453 return qe_invalid;
15454
15455 }
15456 988704 }
15457
15458
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
15459 {
15460
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
15461 {
15462 return qe_invalid;
15463 }
15464
15465 93768 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15466
15467
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15468 {
15469 for(int32_t i=1; i<4; i++)
15470 {
15471 if(!p_getc(&(tempbyte),f))
15472 {
15473 return qe_invalid;
15474 }
15475
15476 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15477 }
15478 }
15479 else
15480 {
15481 93768 temp_mapscr->tilewarpdmap[1]=0;
15482 93768 temp_mapscr->tilewarpdmap[2]=0;
15483 93768 temp_mapscr->tilewarpdmap[3]=0;
15484 }
15485 93768 }
15486 else
15487 {
15488
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
15489 {
15490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15491 {
15492 return qe_invalid;
15493 }
15494 613632 }
15495 }
15496
15497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15498 {
15499 return qe_invalid;
15500 }
15501
15502
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15503 {
15504
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15505 {
15506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15507 {
15508 return qe_invalid;
15509 }
15510 460224 }
15511 153408 }
15512 else
15513 {
15514 93768 temp_mapscr->tilewarpscr[1]=0;
15515 93768 temp_mapscr->tilewarpscr[2]=0;
15516 93768 temp_mapscr->tilewarpscr[3]=0;
15517 }
15518
15519
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15520 {
15521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15522 {
15523 return qe_invalid;
15524 }
15525 153408 }
15526 else
15527 {
15528 93768 temp_mapscr->tilewarpoverlayflags=0;
15529 }
15530
15531
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->exitdir),f))
15532 {
15533 return qe_invalid;
15534 }
15535
15536
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15537 {
15538
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15539 {
15540 return qe_invalid;
15541 }
15542
15543 6864 }
15544
15545
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15546 {
15547 if(!p_getc(&padding,f))
15548 {
15549 return qe_invalid;
15550 }
15551 }
15552
15553
2/2
✓ Branch 0 taken 2471760 times.
✓ Branch 1 taken 247176 times.
2718936 for(int32_t k=0; k<10; k++)
15554 {
15555 /*
15556 if (!temp_mapscr->enemy[k])
15557 {
15558 continue;
15559 }
15560 */
15561
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15562 {
15563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(!p_getc(&tempbyte,f))
15564 {
15565 return qe_invalid;
15566 }
15567
15568 68640 temp_mapscr->enemy[k]=tempbyte;
15569 68640 }
15570 else
15571 {
15572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2403120 times.
2403120 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15573 {
15574 return qe_invalid;
15575 }
15576 }
15577
15578
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15579 {
15580 //using enumerations here is dangerous
15581 //very easy to break old quests -DD
15582
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 67852 times.
68640 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15583 {
15584 788 temp_mapscr->enemy[k]+=5;
15585 788 }
15586
2/2
✓ Branch 0 taken 67812 times.
✓ Branch 1 taken 40 times.
67852 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15587 {
15588 40 temp_mapscr->enemy[k]+=1;
15589 40 }
15590 68640 }
15591
15592
2/2
✓ Branch 0 taken 1534080 times.
✓ Branch 1 taken 937680 times.
2471760 if(version < 9)
15593 {
15594
2/2
✓ Branch 0 taken 856505 times.
✓ Branch 1 taken 81175 times.
937680 if(temp_mapscr->enemy[k]>0)
15595 {
15596 81175 temp_mapscr->enemy[k]+=10;
15597 81175 }
15598 937680 }
15599 //don't read in any invalid data
15600
2/2
✓ Branch 0 taken 2471670 times.
✓ Branch 1 taken 90 times.
2471760 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15601 {
15602 90 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15603 90 temp_mapscr->enemy[k] = 0;
15604 90 }
15605 2471760 }
15606
15607
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->pattern),f))
15608 {
15609 return qe_invalid;
15610 }
15611
15612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15613 {
15614 return qe_invalid;
15615 }
15616
15617
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15618 {
15619
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15620 {
15621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15622 {
15623 return qe_invalid;
15624 }
15625 460224 }
15626 153408 }
15627 else
15628 {
15629 93768 temp_mapscr->sidewarptype[1]=0;
15630 93768 temp_mapscr->sidewarptype[2]=0;
15631 93768 temp_mapscr->sidewarptype[3]=0;
15632 }
15633
15634
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15635 {
15636
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15637 {
15638 return qe_invalid;
15639 }
15640 153408 }
15641 else
15642 {
15643 93768 temp_mapscr->sidewarpoverlayflags=0;
15644 }
15645
15646
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15647 {
15648 return qe_invalid;
15649 }
15650
15651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15652 {
15653 return qe_invalid;
15654 }
15655
15656
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15657 {
15658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->path[k]),f))
15659 {
15660 return qe_invalid;
15661 }
15662 988704 }
15663
15664
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15665 {
15666 return qe_invalid;
15667 }
15668
15669
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15670 {
15671
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 460224 times.
613632 for(int32_t i=1; i<4; i++)
15672 {
15673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15674 {
15675 return qe_invalid;
15676 }
15677 460224 }
15678 153408 }
15679 else
15680 {
15681 93768 temp_mapscr->sidewarpscr[1]=0;
15682 93768 temp_mapscr->sidewarpscr[2]=0;
15683 93768 temp_mapscr->sidewarpscr[3]=0;
15684 }
15685
15686
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
15687 {
15688
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
15689 {
15690 return qe_invalid;
15691 }
15692
15693 93768 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15694
15695
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15696 {
15697 for(int32_t i=1; i<4; i++)
15698 {
15699 if(!p_getc(&(tempbyte),f))
15700 {
15701 return qe_invalid;
15702 }
15703
15704 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15705 }
15706 }
15707 else
15708 {
15709 93768 temp_mapscr->sidewarpdmap[1]=0;
15710 93768 temp_mapscr->sidewarpdmap[2]=0;
15711 93768 temp_mapscr->sidewarpdmap[3]=0;
15712 }
15713 93768 }
15714 else
15715 {
15716
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
15717 {
15718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
15719 {
15720 return qe_invalid;
15721 }
15722 613632 }
15723 }
15724
15725
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15726 {
15727
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
15728 {
15729 return qe_invalid;
15730 }
15731 153408 }
15732 93768 else temp_mapscr->sidewarpindex = 0;
15733
15734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_igetw(&(temp_mapscr->undercombo),f))
15735 {
15736 return qe_invalid;
15737 }
15738
15739
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15740 {
15741
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&(temp_mapscr->old_cpage),f))
15742 {
15743 return qe_invalid;
15744 }
15745 6864 }
15746
15747
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
15748 {
15749 return qe_invalid;
15750 }
15751
15752
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_igetw(&(temp_mapscr->catchall),f))
15753 {
15754 return qe_invalid;
15755 }
15756
15757
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->flags),f))
15758 {
15759 return qe_invalid;
15760 }
15761
15762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags2),f))
15763 {
15764 return qe_invalid;
15765 }
15766
15767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags3),f))
15768 {
15769 return qe_invalid;
15770 }
15771
15772
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
15773 //if (version>2)
15774 {
15775
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags4),f))
15776 {
15777 return qe_invalid;
15778 }
15779 153408 }
15780
15781
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15782 {
15783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags5),f))
15784 {
15785 return qe_invalid;
15786 }
15787
15788
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->noreset),f))
15789 {
15790 return qe_invalid;
15791 }
15792
15793
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->nocarry),f))
15794 {
15795 return qe_invalid;
15796 }
15797
15798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(temp_mapscr->flags5&32)
15799 {
15800 temp_mapscr->flags5 &= ~32;
15801 temp_mapscr->noreset |= 48;
15802 }
15803
15804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(version<8)
15805 {
15806 if(temp_mapscr->noreset&1)
15807 {
15808 temp_mapscr->noreset|=8192;
15809 }
15810
15811 if(temp_mapscr->nocarry&1)
15812 {
15813 temp_mapscr->nocarry|=8192;
15814 temp_mapscr->nocarry&=~1;
15815 }
15816 }
15817 153408 }
15818 else
15819 {
15820 93768 temp_mapscr->flags5 = 0;
15821 93768 temp_mapscr->noreset = 0;
15822 93768 temp_mapscr->nocarry = 0;
15823 }
15824
15825
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
15826 {
15827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags6),f))
15828 {
15829 return qe_invalid;
15830 }
15831 153408 }
15832
15833
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>5)
15834 {
15835
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags7),f))
15836 {
15837 return qe_invalid;
15838 }
15839
15840
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags8),f))
15841 {
15842 return qe_invalid;
15843 }
15844
15845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags9),f))
15846 {
15847 return qe_invalid;
15848 }
15849
15850
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags10),f))
15851 {
15852 return qe_invalid;
15853 }
15854
15855
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->csensitive),f))
15856 {
15857 return qe_invalid;
15858 }
15859 153408 }
15860 else
15861 {
15862 93768 temp_mapscr->csensitive=1;
15863 }
15864
15865
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<14) // August 2007: screen SFX added
15866 {
15867
2/2
✓ Branch 0 taken 93668 times.
✓ Branch 1 taken 100 times.
93768 if(temp_mapscr->flags&8) //fROAR
15868 {
15869 100 temp_mapscr->bosssfx=
15870
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 91 times.
100 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
15871 91 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
15872 WAV_ROAR;
15873 100 }
15874
15875
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 93677 times.
93768 if(temp_mapscr->flags&128) //fSEA
15876 {
15877 91 temp_mapscr->oceansfx=WAV_SEA;
15878 91 }
15879
15880 93768 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
15881 ? 0 : WAV_SECRET;
15882
15883 93768 temp_mapscr->flags3 &= ~66; //64|2
15884 93768 temp_mapscr->flags2 &= ~32;
15885 93768 temp_mapscr->flags &= ~136; // 128|8
15886 93768 }
15887 else
15888 {
15889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->oceansfx),f))
15890 {
15891 return qe_invalid;
15892 }
15893
15894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->bosssfx),f))
15895 {
15896 return qe_invalid;
15897 }
15898
15899
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->secretsfx),f))
15900 {
15901 return qe_invalid;
15902 }
15903 }
15904
15905
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<15) // October 2007: another SFX
15906 {
15907 93768 temp_mapscr->holdupsfx=WAV_PICKUP;
15908 93768 }
15909 else
15910 {
15911
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->holdupsfx),f))
15912 {
15913 return qe_invalid;
15914 }
15915 }
15916
15917
15918
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
15919 {
15920
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
15921 {
15922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layermap[k]),f))
15923 {
15924 return qe_invalid;
15925 }
15926 1441872 }
15927
15928
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 1441872 times.
1682184 for(int32_t k=0; k<6; k++)
15929 {
15930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
15931 {
15932 return qe_invalid;
15933 }
15934 1441872 }
15935 240312 }
15936
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6864 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
15937 {
15938 if(!p_getc(&(temp_mapscr->layermap[2]),f))
15939 {
15940 return qe_invalid;
15941 }
15942
15943 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
15944 {
15945 return qe_invalid;
15946 }
15947
15948 if(!p_getc(&(temp_mapscr->layermap[4]),f))
15949 {
15950 return qe_invalid;
15951 }
15952
15953 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
15954
15955 {
15956 return qe_invalid;
15957 }
15958 }
15959
15960
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>149))
15961 {
15962 for(int32_t k=0; k<6; k++)
15963 {
15964 if(!p_getc(&tempbyte,f)) //layerxsize
15965 {
15966 return qe_invalid;
15967 }
15968 }
15969
15970 for(int32_t k=0; k<6; k++)
15971 {
15972 if(!p_getc(&tempbyte,f)) //layerxspeed
15973 {
15974 return qe_invalid;
15975 }
15976 }
15977
15978 for(int32_t k=0; k<6; k++)
15979 {
15980 if(!p_getc(&tempbyte,f)) //layerxdelay
15981 {
15982 return qe_invalid;
15983 }
15984 }
15985
15986 for(int32_t k=0; k<6; k++)
15987 {
15988 if(!p_getc(&tempbyte,f)) //layerysize
15989 {
15990 return qe_invalid;
15991 }
15992 }
15993
15994 for(int32_t k=0; k<6; k++)
15995 {
15996 if(!p_getc(&tempbyte,f)) //layeryspeed
15997 {
15998 return qe_invalid;
15999 }
16000 }
16001
16002 for(int32_t k=0; k<6; k++)
16003 {
16004 if(!p_getc(&tempbyte,f)) //layerydelay
16005 {
16006 return qe_invalid;
16007 }
16008 }
16009 }
16010
16011
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16012 {
16013
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
16014 {
16015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16016 {
16017 return qe_invalid;
16018 }
16019 1441872 }
16020 240312 }
16021
16022
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16023 {
16024
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 if((Header->zelda_version == 0x192)&&(Header->build>153))
16025 {
16026 if(!p_getc(&padding,f))
16027 {
16028 return qe_invalid;
16029 }
16030 }
16031
16032
1/2
✓ Branch 0 taken 240312 times.
✗ Branch 1 not taken.
240312 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16033 {
16034 return qe_invalid;
16035 }
16036 240312 }
16037
16038
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16039 {
16040 6864 extras=15;
16041 6864 }
16042
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16043 {
16044 extras=11;
16045 }
16046
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16047 {
16048 extras=32;
16049 }
16050
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16051 {
16052 extras=64;
16053 }
16054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 else if(Header->zelda_version < 0x193)
16055 {
16056 extras=62;
16057 }
16058 else
16059
16060 {
16061 240312 extras=0;
16062 }
16063
16064
2/2
✓ Branch 0 taken 102960 times.
✓ Branch 1 taken 247176 times.
350136 for(int32_t k=0; k<extras; k++)
16065 {
16066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102960 times.
102960 if(!p_getc(&tempbyte,f)) //extra[k]
16067 {
16068 return qe_invalid;
16069 }
16070 102960 }
16071
16072
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16073 //if (version>3)
16074 {
16075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->nextmap),f))
16076 {
16077 return qe_invalid;
16078 }
16079
16080
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->nextscr),f))
16081 {
16082 return qe_invalid;
16083 }
16084 153408 }
16085 else
16086 {
16087 93768 temp_mapscr->nextmap=0;
16088 93768 temp_mapscr->nextscr=0;
16089 }
16090
16091
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16092 {
16093 6864 secretcombos=20;
16094 6864 }
16095
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16096 {
16097 secretcombos=256;
16098 }
16099 else
16100 {
16101 240312 secretcombos=128;
16102 }
16103
16104
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16105 {
16106
2/2
✓ Branch 0 taken 137280 times.
✓ Branch 1 taken 6864 times.
144144 for(int32_t k=0; k<secretcombos; k++)
16107 {
16108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(!p_getc(&tempbyte,f))
16109 {
16110 return qe_invalid;
16111 }
16112
16113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(k<128)
16114 {
16115 137280 temp_mapscr->secretcombo[k]=tempbyte;
16116 137280 }
16117 137280 }
16118 6864 }
16119 else
16120 {
16121
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16122 {
16123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16124 {
16125 return qe_invalid;
16126 }
16127
16128 30759936 }
16129 }
16130
16131
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16132 {
16133
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16134 {
16135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16136 {
16137 return qe_invalid;
16138 }
16139 30759936 }
16140
16141
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16142 {
16143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16144 {
16145 return qe_invalid;
16146 }
16147 30759936 }
16148 240312 }
16149
16150
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16151 {
16152 if(!p_getc(&padding,f))
16153 {
16154 return qe_invalid;
16155 }
16156 }
16157
16158 247176 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16159
16160
2/2
✓ Branch 0 taken 43502976 times.
✓ Branch 1 taken 247176 times.
43750152 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16161 {
16162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43502976 times.
43502976 if(!p_igetw(&(temp_mapscr->data[k]),f))
16163 {
16164 return qe_invalid;
16165 }
16166 43502976 }
16167
16168
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16169 {
16170 if(!p_getc(&padding,f))
16171 {
16172 return qe_invalid;
16173 }
16174
16175 if(!p_getc(&padding,f))
16176 {
16177 return qe_invalid;
16178 }
16179 }
16180
16181
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16182 {
16183
2/2
✓ Branch 0 taken 42294912 times.
✓ Branch 1 taken 240312 times.
42535224 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16184 {
16185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16186 {
16187 return qe_invalid;
16188 }
16189
16190
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42294912 if((Header->zelda_version == 0x192)&&(Header->build<24))
16191 {
16192 if(!p_getc(&tempbyte,f))
16193 {
16194 return qe_invalid;
16195 }
16196
16197 if(!p_getc(&tempbyte,f))
16198 {
16199 return qe_invalid;
16200 }
16201
16202 if(!p_getc(&tempbyte,f))
16203 {
16204 return qe_invalid;
16205 }
16206 }
16207 42294912 }
16208 240312 }
16209
16210
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16211 {
16212
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 42294912 times.
42535224 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16213 {
16214
16215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->cset[k]),f))
16216 {
16217 return qe_invalid;
16218 }
16219 42294912 }
16220 240312 }
16221
16222
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16223 {
16224 6864 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16225 6864 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16226 6864 }
16227
16228
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16229 {
16230 6864 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16231 6864 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16232 6864 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16233 6864 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16234 6864 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16235 6864 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16236 6864 }
16237
16238
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16239 {
16240
2/2
✓ Branch 0 taken 1208064 times.
✓ Branch 1 taken 6864 times.
1214928 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16241 {
16242
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version == 0x192)&&(Header->build>149))
16243 {
16244 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16245 {
16246 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16247 }
16248 }
16249 else
16250 {
16251
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version < 0x192)||
16252 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16253 {
16254 1208064 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16255 1208064 }
16256
16257 1208064 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16258 }
16259
16260 1208064 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16261 1208064 }
16262 6864 }
16263
16264 /*if(version>12)
16265 {
16266 if(!p_getc(&(temp_mapscr->scrWidth),f))
16267 {
16268 return qe_invalid;
16269 }
16270 if(!p_getc(&(temp_mapscr->scrHeight),f))
16271 {
16272 return qe_invalid;
16273 }
16274 }*/
16275
16276
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>4)
16277 {
16278
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16279 {
16280 return qe_invalid;
16281 }
16282 153408 }
16283 else
16284 {
16285 93768 temp_mapscr->screen_midi = -1;
16286 }
16287
16288
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>=17)
16289 {
16290
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->lens_layer),f))
16291 {
16292 return qe_invalid;
16293 }
16294 153408 }
16295 else
16296 {
16297 93768 temp_mapscr->lens_layer = llNORMAL;
16298 }
16299
16300
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version>6)
16301 {
16302 dword bits;
16303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_igetl(&bits,f))
16304 {
16305 return qe_invalid;
16306 }
16307
16308 int32_t m;
16309 float tempfloat;
16310 word tempw;
16311 153408 temp_mapscr->ffcCountMarkDirty();
16312
16313
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 4909056 times.
5062464 for(m=0; m<32; m++)
16314 {
16315 4909056 ffcdata& tempffc = temp_mapscr->ffcs[m];
16316 4909056 tempffc.clear();
16317
2/2
✓ Branch 0 taken 4886067 times.
✓ Branch 1 taken 22989 times.
4909056 if((bits>>m)&1)
16318 {
16319
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetw(&tempw,f))
16320 {
16321 return qe_invalid;
16322 }
16323 22989 tempffc.setData(tempw);
16324
16325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.cset),f))
16326 {
16327 return qe_invalid;
16328 }
16329
16330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.delay),f))
16331 {
16332 return qe_invalid;
16333 }
16334
16335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(version < 9)
16336 {
16337 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16338 {
16339 return qe_invalid;
16340 }
16341
16342 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16343
16344 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16345 {
16346 return qe_invalid;
16347 }
16348
16349 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16350
16351 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16352 {
16353 return qe_invalid;
16354 }
16355
16356 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16357
16358 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16359 {
16360 return qe_invalid;
16361 }
16362
16363 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16364
16365 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16366 {
16367 return qe_invalid;
16368 }
16369
16370 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16371
16372 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16373 {
16374 return qe_invalid;
16375 }
16376
16377 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16378 }
16379 else
16380 {
16381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.x),f))
16382 {
16383 return qe_invalid;
16384 }
16385
16386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.y),f))
16387 {
16388 return qe_invalid;
16389 }
16390
16391
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetzf(&(tempffc.vx),f))
16392 {
16393 return qe_invalid;
16394 }
16395
16396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.vy),f))
16397 {
16398 return qe_invalid;
16399 }
16400
16401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ax),f))
16402 {
16403 return qe_invalid;
16404 }
16405
16406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ay),f))
16407 {
16408 return qe_invalid;
16409 }
16410 }
16411
16412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.link),f))
16413 {
16414 return qe_invalid;
16415 }
16416
16417
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>7)
16418 {
16419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16420 {
16421 return qe_invalid;
16422 }
16423
16424 22989 tempffc.hit_width = (tempbyte&0x3F)+1;
16425 22989 tempffc.txsz = (tempbyte>>6)+1;
16426
16427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16428 {
16429 return qe_invalid;
16430 }
16431
16432 22989 tempffc.hit_height = (tempbyte&0x3F)+1;
16433 22989 tempffc.tysz = (tempbyte>>6)+1;
16434
16435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.flags),f))
16436 {
16437 return qe_invalid;
16438 }
16439 22989 }
16440 else
16441 {
16442 tempffc.hit_width=16;
16443 tempffc.hit_height=16;
16444 tempffc.txsz=1;
16445 tempffc.tysz=1;
16446 tempffc.flags=0;
16447 }
16448
16449 22989 tempffc.updateSolid();
16450
16451
16452
4/6
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20969 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20969 times.
22989 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16453 {
16454 tempffc.flags|=ffIGNOREHOLDUP;
16455 }
16456
16457
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>9)
16458 {
16459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.script),f))
16460 {
16461 return qe_invalid;
16462 }
16463 22989 }
16464 else
16465 {
16466 tempffc.script=0;
16467 }
16468
16469
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>10)
16470 {
16471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[0]),f))
16472 {
16473 return qe_invalid;
16474 }
16475
16476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[1]),f))
16477 {
16478 return qe_invalid;
16479 }
16480
16481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[2]),f))
16482 {
16483 return qe_invalid;
16484 }
16485
16486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[3]),f))
16487 {
16488 return qe_invalid;
16489 }
16490
16491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[4]),f))
16492 {
16493 return qe_invalid;
16494 }
16495
16496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[5]),f))
16497 {
16498 return qe_invalid;
16499 }
16500
16501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[6]),f))
16502 {
16503 return qe_invalid;
16504 }
16505
16506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[7]),f))
16507 {
16508 return qe_invalid;
16509 }
16510
16511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16512 {
16513 return qe_invalid;
16514 }
16515
16516 22989 tempffc.inita[0]=tempbyte*10000;
16517
16518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16519 {
16520 return qe_invalid;
16521 }
16522
16523 22989 tempffc.inita[1]=tempbyte*10000;
16524 22989 }
16525 else
16526 {
16527 tempffc.inita[0] = 10000;
16528 tempffc.inita[1] = 10000;
16529 }
16530
16531
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version <= 11)
16532 {
16533 fixffcs=true;
16534 }
16535 22989 }
16536 4909056 }
16537
2/2
✓ Branch 0 taken 14727168 times.
✓ Branch 1 taken 153408 times.
14880576 for(m = 32; m < MAXFFCS; ++m)
16538 {
16539 14727168 temp_mapscr->ffcs[m].clear();
16540 14727168 }
16541 153408 }
16542
16543 //add in the new whistle flags
16544
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version<13)
16545 {
16546
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 93749 times.
93768 if(temp_mapscr->flags & fWHISTLE)
16547 {
16548 19 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16549 19 }
16550 93768 }
16551
16552 //2.55 starts here
16553
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 19 && Header->zelda_version > 0x253 )
16554 {
16555
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16556 {
16557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16558 {
16559 return qe_invalid;
16560 }
16561 137360 }
16562
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16563 {
16564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16565 {
16566 return qe_invalid;
16567 }
16568 137360 }
16569
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16570 {
16571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16572 {
16573 return qe_invalid;
16574 }
16575 137360 }
16576
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16577 {
16578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16579 {
16580 return qe_invalid;
16581 }
16582 137360 }
16583 13736 }
16584
3/4
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 233440 times.
247176 if ( version < 19 && Header->zelda_version > 0x253 )
16585 {
16586 for ( int32_t q = 0; q < 10; q++ )
16587 {
16588 temp_mapscr->npcstrings[q] = 0;
16589 temp_mapscr->new_items[q] = 0;
16590 temp_mapscr->new_item_x[q] = 0;
16591 temp_mapscr->new_item_y[q] = 0;
16592 }
16593 }
16594
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 20 && Header->zelda_version > 0x253 )
16595 {
16596
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f))
16597 {
16598 return qe_invalid;
16599 }
16600
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
16601 {
16602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16603 {
16604 return qe_invalid;
16605 }
16606 109888 }
16607 13736 }
16608
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
247176 if ( version < 20 )
16609 {
16610 233440 temp_mapscr->script = 0;
16611
2/2
✓ Branch 0 taken 1867520 times.
✓ Branch 1 taken 233440 times.
2100960 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16612 233440 }
16613
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 21 && Header->zelda_version > 0x253 )
16614 {
16615
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f))
16616 {
16617 return qe_invalid;
16618 }
16619 13736 }
16620
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 21 )
16621 {
16622 233440 temp_mapscr->preloadscript = 0;
16623 233440 }
16624 //all builds with version > 20 need this. -Z
16625
16626
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16627 {
16628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16629 {
16630 return qe_invalid;
16631 }
16632
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16633 {
16634 return qe_invalid;
16635 }
16636 13736 }
16637
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 22 )
16638 {
16639 233440 temp_mapscr->hidelayers = 0;
16640 233440 temp_mapscr->hidescriptlayers = 0;
16641 233440 }
16642
16643 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16644 //May be any version before 2.11. -Z
16645 /* --not the roar, the HIT SFX
16646 if ( Header->zelda_version <= 0x210 )
16647 {
16648 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16649 {
16650 temp_mapscr->bosssfx = WAV_ROAR;
16651 }
16652 }
16653 */
16654
16655 247176 return 0;
16656 247176 }
16657 263904 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version, int scrind)
16658 {
16659
2/2
✓ Branch 0 taken 247176 times.
✓ Branch 1 taken 16728 times.
263904 if(version < 23)
16660 {
16661 247176 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
16662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(ret) return ret;
16663 247176 }
16664 else
16665 {
16666
1/2
✓ Branch 0 taken 16728 times.
✗ Branch 1 not taken.
16728 if(!p_getc(&(temp_mapscr->valid),f))
16667 return qe_invalid;
16668
2/2
✓ Branch 0 taken 10619 times.
✓ Branch 1 taken 6109 times.
16728 if(!(temp_mapscr->valid & mVALID))
16669 {
16670 10619 int map = scrind/MAPSCRS;
16671 10619 int scr = scrind%MAPSCRS;
16672
4/6
✓ Branch 0 taken 6808 times.
✓ Branch 1 taken 3811 times.
✓ Branch 2 taken 6808 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6808 times.
✗ Branch 5 not taken.
10619 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16673 {
16674 //Empty screen, apply autolayers
16675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6808 times.
6808 for(int q = 0; q < 6; ++q)
16676 {
16677 auto layermap = map_autolayers[map*6+q];
16678 temp_mapscr->layermap[q] = layermap;
16679 if(layermap)
16680 temp_mapscr->layerscreen[q] = scr;
16681 }
16682 6808 }
16683 10619 return 0;
16684 }
16685 uint32_t scr_has_flags;
16686
1/2
✓ Branch 0 taken 6109 times.
✗ Branch 1 not taken.
6109 if(!p_igetl(&scr_has_flags,f))
16687 return qe_invalid;
16688
16689
2/2
✓ Branch 0 taken 5241 times.
✓ Branch 1 taken 868 times.
6109 if(scr_has_flags & SCRHAS_ROOMDATA)
16690 {
16691
1/2
✓ Branch 0 taken 868 times.
✗ Branch 1 not taken.
868 if(!p_getc(&(temp_mapscr->guy),f))
16692 return qe_invalid;
16693
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 60 times.
868 if(version > 26)
16694 {
16695
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if(!p_igetl(&(temp_mapscr->guytile),f))
16696 return qe_invalid;
16697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 if(!p_getc(&(temp_mapscr->guycs),f))
16698 return qe_invalid;
16699
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if(!p_igetw(&(temp_mapscr->roomflags),f))
16700 return qe_invalid;
16701 808 }
16702 else
16703 {
16704 60 temp_mapscr->guytile = -1; //signal to use default guy values
16705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
16706
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
16707 }
16708
1/2
✓ Branch 0 taken 868 times.
✗ Branch 1 not taken.
868 if(!p_igetw(&(temp_mapscr->str),f))
16709 return qe_invalid;
16710
1/2
✓ Branch 0 taken 868 times.
✗ Branch 1 not taken.
868 if(!p_getc(&(temp_mapscr->room),f))
16711 return qe_invalid;
16712
1/2
✓ Branch 0 taken 868 times.
✗ Branch 1 not taken.
868 if(!p_igetw(&(temp_mapscr->catchall),f))
16713 return qe_invalid;
16714 868 }
16715
2/2
✓ Branch 0 taken 5984 times.
✓ Branch 1 taken 125 times.
6109 if(scr_has_flags & SCRHAS_ITEM)
16716 {
16717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(!p_getc(&(temp_mapscr->item),f))
16718 return qe_invalid;
16719
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&(temp_mapscr->hasitem),f))
16720 return qe_invalid;
16721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(!p_getc(&(temp_mapscr->itemx),f))
16722 return qe_invalid;
16723
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&(temp_mapscr->itemy),f))
16724 return qe_invalid;
16725 125 }
16726
2/2
✓ Branch 0 taken 5751 times.
✓ Branch 1 taken 358 times.
6109 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16727 {
16728
1/2
✓ Branch 0 taken 358 times.
✗ Branch 1 not taken.
358 if(!p_igetw(&temp_mapscr->warpreturnc,f))
16729 return qe_invalid;
16730 358 }
16731
2/2
✓ Branch 0 taken 5864 times.
✓ Branch 1 taken 245 times.
6109 if(scr_has_flags & SCRHAS_TWARP)
16732 {
16733
2/2
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 245 times.
1225 for(int32_t i=0; i<4; i++)
16734 {
16735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 980 times.
980 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
16736 return qe_invalid;
16737 980 }
16738
2/2
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 245 times.
1225 for(int32_t i=0; i<4; i++)
16739 {
16740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 980 times.
980 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
16741 return qe_invalid;
16742 980 }
16743
2/2
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 245 times.
1225 for(int32_t i=0; i<4; i++)
16744 {
16745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 980 times.
980 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
16746 return qe_invalid;
16747 980 }
16748
1/2
✓ Branch 0 taken 245 times.
✗ Branch 1 not taken.
245 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
16749 return qe_invalid;
16750 245 }
16751
2/2
✓ Branch 0 taken 5970 times.
✓ Branch 1 taken 139 times.
6109 if(scr_has_flags & SCRHAS_SWARP)
16752 {
16753
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
16754 {
16755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16756 return qe_invalid;
16757 556 }
16758
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
16759 {
16760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16761 return qe_invalid;
16762 556 }
16763
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
16764 {
16765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16766 return qe_invalid;
16767 556 }
16768
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16769 return qe_invalid;
16770
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16771 return qe_invalid;
16772 139 }
16773
2/2
✓ Branch 0 taken 5667 times.
✓ Branch 1 taken 442 times.
6109 if(scr_has_flags & SCRHAS_WARPRET)
16774 {
16775
2/2
✓ Branch 0 taken 1768 times.
✓ Branch 1 taken 442 times.
2210 for(int32_t i=0; i<4; i++)
16776 {
16777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1768 times.
1768 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
16778 return qe_invalid;
16779 1768 }
16780
2/2
✓ Branch 0 taken 1768 times.
✓ Branch 1 taken 442 times.
2210 for(int32_t i=0; i<4; i++)
16781 {
16782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1768 times.
1768 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
16783 return qe_invalid;
16784 1768 }
16785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 442 times.
442 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16786 return qe_invalid;
16787
1/2
✓ Branch 0 taken 442 times.
✗ Branch 1 not taken.
442 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16788 return qe_invalid;
16789 442 }
16790
2/2
✓ Branch 0 taken 4979 times.
✓ Branch 1 taken 1130 times.
6109 if(scr_has_flags & SCRHAS_LAYERS)
16791 {
16792
2/2
✓ Branch 0 taken 6780 times.
✓ Branch 1 taken 1130 times.
7910 for(int32_t k=0; k<6; k++)
16793 {
16794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6780 times.
6780 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16795 return qe_invalid;
16796 6780 }
16797
2/2
✓ Branch 0 taken 6780 times.
✓ Branch 1 taken 1130 times.
7910 for(int32_t k=0; k<6; k++)
16798 {
16799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6780 times.
6780 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16800 return qe_invalid;
16801 6780 }
16802
2/2
✓ Branch 0 taken 6780 times.
✓ Branch 1 taken 1130 times.
7910 for(int32_t k=0; k<6; k++)
16803 {
16804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6780 times.
6780 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16805 return qe_invalid;
16806 6780 }
16807
1/2
✓ Branch 0 taken 1130 times.
✗ Branch 1 not taken.
1130 if(!p_getc(&(temp_mapscr->hidelayers),f))
16808 return qe_invalid;
16809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1130 times.
1130 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
16810 return qe_invalid;
16811 1130 }
16812
1/2
✓ Branch 0 taken 6109 times.
✗ Branch 1 not taken.
6109 if(scr_has_flags & SCRHAS_MAZE)
16813 {
16814 for(int32_t k=0; k<4; k++)
16815 {
16816 if(!p_getc(&(temp_mapscr->path[k]),f))
16817 return qe_invalid;
16818 }
16819 if(!p_getc(&(temp_mapscr->exitdir),f))
16820 return qe_invalid;
16821 }
16822
2/2
✓ Branch 0 taken 5948 times.
✓ Branch 1 taken 161 times.
6109 if(scr_has_flags & SCRHAS_D_S_U)
16823 {
16824
1/2
✓ Branch 0 taken 161 times.
✗ Branch 1 not taken.
161 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
16825 return qe_invalid;
16826
2/2
✓ Branch 0 taken 644 times.
✓ Branch 1 taken 161 times.
805 for(int32_t k=0; k<4; k++)
16827 {
16828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 644 times.
644 if(!p_getc(&(temp_mapscr->door[k]),f))
16829 return qe_invalid;
16830 644 }
16831
16832
1/2
✓ Branch 0 taken 161 times.
✗ Branch 1 not taken.
161 if(!p_getc(&(temp_mapscr->stairx),f))
16833 return qe_invalid;
16834
16835
1/2
✓ Branch 0 taken 161 times.
✗ Branch 1 not taken.
161 if(!p_getc(&(temp_mapscr->stairy),f))
16836 return qe_invalid;
16837
1/2
✓ Branch 0 taken 161 times.
✗ Branch 1 not taken.
161 if(!p_igetw(&(temp_mapscr->undercombo),f))
16838 return qe_invalid;
16839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161 times.
161 if(!p_getc(&(temp_mapscr->undercset),f))
16840 return qe_invalid;
16841 161 }
16842
2/2
✓ Branch 0 taken 5670 times.
✓ Branch 1 taken 439 times.
6109 if(scr_has_flags & SCRHAS_FLAGS)
16843 {
16844
1/2
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
439 if(!p_getc(&(temp_mapscr->flags),f))
16845 return qe_invalid;
16846
1/2
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
439 if(!p_getc(&(temp_mapscr->flags2),f))
16847 return qe_invalid;
16848
1/2
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
439 if(!p_getc(&(temp_mapscr->flags3),f))
16849 return qe_invalid;
16850
1/2
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
439 if(!p_getc(&(temp_mapscr->flags4),f))
16851 return qe_invalid;
16852
1/2
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
439 if(!p_getc(&(temp_mapscr->flags5),f))
16853 return qe_invalid;
16854
1/2
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
439 if(!p_getc(&(temp_mapscr->flags6),f))
16855 return qe_invalid;
16856
1/2
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
439 if(!p_getc(&(temp_mapscr->flags7),f))
16857 return qe_invalid;
16858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 439 times.
439 if(!p_getc(&(temp_mapscr->flags8),f))
16859 return qe_invalid;
16860
1/2
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
439 if(!p_getc(&(temp_mapscr->flags9),f))
16861 return qe_invalid;
16862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 439 times.
439 if(!p_getc(&(temp_mapscr->flags10),f))
16863 return qe_invalid;
16864
1/2
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
439 if(!p_getc(&(temp_mapscr->enemyflags),f))
16865 return qe_invalid;
16866 439 }
16867
2/2
✓ Branch 0 taken 5728 times.
✓ Branch 1 taken 381 times.
6109 if(scr_has_flags & SCRHAS_ENEMY)
16868 {
16869
2/2
✓ Branch 0 taken 3810 times.
✓ Branch 1 taken 381 times.
4191 for(int32_t k=0; k<10; k++)
16870 {
16871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3810 times.
3810 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
16872 return qe_invalid;
16873
1/2
✓ Branch 0 taken 3810 times.
✗ Branch 1 not taken.
3810 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
16874 temp_mapscr->enemy[k] = 0;
16875 3810 }
16876
1/2
✓ Branch 0 taken 381 times.
✗ Branch 1 not taken.
381 if(!p_getc(&(temp_mapscr->pattern),f))
16877 return qe_invalid;
16878 381 }
16879
2/2
✓ Branch 0 taken 6076 times.
✓ Branch 1 taken 33 times.
6109 if(scr_has_flags & SCRHAS_CARRY)
16880 {
16881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(!p_igetw(&(temp_mapscr->noreset),f))
16882 return qe_invalid;
16883
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&(temp_mapscr->nocarry),f))
16884 return qe_invalid;
16885
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextmap),f))
16886 return qe_invalid;
16887
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextscr),f))
16888 return qe_invalid;
16889 33 }
16890
2/2
✓ Branch 0 taken 6038 times.
✓ Branch 1 taken 71 times.
6109 if(scr_has_flags & SCRHAS_SCRIPT)
16891 {
16892
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 if(!p_igetw(&(temp_mapscr->script),f))
16893 return qe_invalid;
16894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(!p_getc(&(temp_mapscr->preloadscript),f))
16895 return qe_invalid;
16896
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 71 times.
639 for ( int32_t q = 0; q < 8; q++ )
16897 {
16898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 568 times.
568 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16899 return qe_invalid;
16900 568 }
16901 71 }
16902
1/2
✓ Branch 0 taken 6109 times.
✗ Branch 1 not taken.
6109 if(scr_has_flags & SCRHAS_UNUSED)
16903 {
16904 for ( int32_t q = 0; q < 10; q++ )
16905 {
16906 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16907 return qe_invalid;
16908 }
16909 for ( int32_t q = 0; q < 10; q++ )
16910 {
16911 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16912 return qe_invalid;
16913 }
16914 for ( int32_t q = 0; q < 10; q++ )
16915 {
16916 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16917 return qe_invalid;
16918 }
16919 for ( int32_t q = 0; q < 10; q++ )
16920 {
16921 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16922 return qe_invalid;
16923 }
16924 }
16925
2/2
✓ Branch 0 taken 5684 times.
✓ Branch 1 taken 425 times.
6109 if(scr_has_flags & SCRHAS_SECRETS)
16926 {
16927
2/2
✓ Branch 0 taken 54400 times.
✓ Branch 1 taken 425 times.
54825 for(int32_t k=0; k<128; k++)
16928 {
16929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54400 times.
54400 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16930 return qe_invalid;
16931 54400 }
16932
2/2
✓ Branch 0 taken 54400 times.
✓ Branch 1 taken 425 times.
54825 for(int32_t k=0; k<128; k++)
16933 {
16934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54400 times.
54400 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16935 return qe_invalid;
16936 54400 }
16937
2/2
✓ Branch 0 taken 54400 times.
✓ Branch 1 taken 425 times.
54825 for(int32_t k=0; k<128; k++)
16938 {
16939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54400 times.
54400 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16940 return qe_invalid;
16941 54400 }
16942 425 }
16943
2/2
✓ Branch 0 taken 2945 times.
✓ Branch 1 taken 3164 times.
6109 if(scr_has_flags & SCRHAS_COMBOFLAG)
16944 {
16945
2/2
✓ Branch 0 taken 556864 times.
✓ Branch 1 taken 3164 times.
560028 for(int32_t k=0; k<176; ++k)
16946 {
16947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556864 times.
556864 if(!p_igetw(&(temp_mapscr->data[k]),f))
16948 return qe_invalid;
16949 556864 }
16950
2/2
✓ Branch 0 taken 556864 times.
✓ Branch 1 taken 3164 times.
560028 for(int32_t k=0; k<176; ++k)
16951 {
16952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556864 times.
556864 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16953 return qe_invalid;
16954 556864 }
16955
2/2
✓ Branch 0 taken 556864 times.
✓ Branch 1 taken 3164 times.
560028 for(int32_t k=0; k<176; ++k)
16956 {
16957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556864 times.
556864 if(!p_getc(&(temp_mapscr->cset[k]),f))
16958 return qe_invalid;
16959 556864 }
16960 3164 }
16961
1/2
✓ Branch 0 taken 6109 times.
✗ Branch 1 not taken.
6109 if(scr_has_flags & SCRHAS_MISC)
16962 {
16963
1/2
✓ Branch 0 taken 6109 times.
✗ Branch 1 not taken.
6109 if(!p_igetw(&(temp_mapscr->color),f))
16964 return qe_invalid;
16965
1/2
✓ Branch 0 taken 6109 times.
✗ Branch 1 not taken.
6109 if(!p_getc(&(temp_mapscr->csensitive),f))
16966 return qe_invalid;
16967
1/2
✓ Branch 0 taken 6109 times.
✗ Branch 1 not taken.
6109 if(!p_getc(&(temp_mapscr->oceansfx),f))
16968 return qe_invalid;
16969
1/2
✓ Branch 0 taken 6109 times.
✗ Branch 1 not taken.
6109 if(!p_getc(&(temp_mapscr->bosssfx),f))
16970 return qe_invalid;
16971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6109 times.
6109 if(!p_getc(&(temp_mapscr->secretsfx),f))
16972 return qe_invalid;
16973
1/2
✓ Branch 0 taken 6109 times.
✗ Branch 1 not taken.
6109 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16974 return qe_invalid;
16975
1/2
✓ Branch 0 taken 6109 times.
✗ Branch 1 not taken.
6109 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16976 return qe_invalid;
16977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6109 times.
6109 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16978 return qe_invalid;
16979
1/2
✓ Branch 0 taken 6109 times.
✗ Branch 1 not taken.
6109 if(!p_getc(&(temp_mapscr->lens_layer),f))
16980 return qe_invalid;
16981
2/2
✓ Branch 0 taken 5301 times.
✓ Branch 1 taken 808 times.
6109 if(version > 27)
16982 {
16983
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if(!p_getc(&(temp_mapscr->lens_show),f))
16984 return qe_invalid;
16985
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if(!p_getc(&(temp_mapscr->lens_hide),f))
16986 return qe_invalid;
16987 808 }
16988 6109 }
16989 else
16990 {
16991 temp_mapscr->screen_midi = -1;
16992 temp_mapscr->csensitive = 1;
16993 }
16994 //FFC
16995 6109 bool old_ff = version < 25;
16996 6109 dword bits = 0;
16997 6109 word numffc = 32;
16998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6109 times.
6109 if(old_ff)
16999 {
17000 if(!p_igetl(&bits,f))
17001 return qe_invalid;
17002 }
17003 else
17004 {
17005
1/2
✓ Branch 0 taken 6109 times.
✗ Branch 1 not taken.
6109 if(!p_igetw(&numffc,f))
17006 return qe_invalid;
17007 }
17008 byte tempbyte;
17009 word tempw;
17010
4/6
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 6076 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 33 times.
6109 static ffcdata nil_ffc;
17011 6109 temp_mapscr->ffcCountMarkDirty();
17012
2/2
✓ Branch 0 taken 6109 times.
✓ Branch 1 taken 8373 times.
14482 for(word m = 0; m < numffc; ++m)
17013 {
17014
1/2
✓ Branch 0 taken 8373 times.
✗ Branch 1 not taken.
8373 ffcdata& tempffc = (m < MAXFFCS)
17015 8373 ? temp_mapscr->ffcs[m]
17016 : nil_ffc; //sanity
17017 8373 tempffc.clear();
17018
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8373 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8373 if(old_ff && !(bits & (1<<m))) continue;
17019
17020
1/2
✓ Branch 0 taken 8373 times.
✗ Branch 1 not taken.
8373 if(!p_igetw(&tempw,f))
17021 return qe_invalid;
17022
3/4
✓ Branch 0 taken 8373 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1575 times.
✓ Branch 3 taken 6798 times.
8373 if(!old_ff && !tempw) //empty ffc, nothing more to load
17023 6798 continue;
17024 1575 tempffc.setData(tempw);
17025
17026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1575 times.
1575 if(!p_getc(&(tempffc.cset),f))
17027 return qe_invalid;
17028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1575 times.
1575 if(!p_igetw(&(tempffc.delay),f))
17029 return qe_invalid;
17030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1575 times.
1575 if(!p_igetzf(&(tempffc.x),f))
17031 return qe_invalid;
17032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1575 times.
1575 if(!p_igetzf(&(tempffc.y),f))
17033 return qe_invalid;
17034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1575 times.
1575 if(!p_igetzf(&(tempffc.vx),f))
17035 return qe_invalid;
17036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1575 times.
1575 if(!p_igetzf(&(tempffc.vy),f))
17037 return qe_invalid;
17038
1/2
✓ Branch 0 taken 1575 times.
✗ Branch 1 not taken.
1575 if(!p_igetzf(&(tempffc.ax),f))
17039 return qe_invalid;
17040
1/2
✓ Branch 0 taken 1575 times.
✗ Branch 1 not taken.
1575 if(!p_igetzf(&(tempffc.ay),f))
17041 return qe_invalid;
17042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1575 times.
1575 if(!p_getc(&(tempffc.link),f))
17043 return qe_invalid;
17044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1575 times.
1575 if(version < 24)
17045 {
17046 if(!p_getc(&tempbyte,f))
17047 return qe_invalid;
17048 tempffc.hit_width = (tempbyte&0x3F)+1;
17049 tempffc.txsz = (tempbyte>>6)+1;
17050 if(!p_getc(&tempbyte,f))
17051 return qe_invalid;
17052 tempffc.hit_height = (tempbyte&0x3F)+1;
17053 tempffc.tysz = (tempbyte>>6)+1;
17054 }
17055 else
17056 {
17057
1/2
✓ Branch 0 taken 1575 times.
✗ Branch 1 not taken.
1575 if(!p_igetl(&(tempffc.hit_width),f))
17058 return qe_invalid;
17059
1/2
✓ Branch 0 taken 1575 times.
✗ Branch 1 not taken.
1575 if(!p_igetl(&(tempffc.hit_height),f))
17060 return qe_invalid;
17061
1/2
✓ Branch 0 taken 1575 times.
✗ Branch 1 not taken.
1575 if(!p_getc(&(tempffc.txsz),f))
17062 return qe_invalid;
17063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1575 times.
1575 if(!p_getc(&(tempffc.tysz),f))
17064 return qe_invalid;
17065 }
17066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1575 times.
1575 if(!p_igetl(&(tempffc.flags),f))
17067 return qe_invalid;
17068 1575 tempffc.updateSolid();
17069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1575 times.
1575 if(!p_igetw(&(tempffc.script),f))
17070 return qe_invalid;
17071
2/2
✓ Branch 0 taken 12600 times.
✓ Branch 1 taken 1575 times.
14175 for(auto q = 0; q < 8; ++q)
17072 {
17073
1/2
✓ Branch 0 taken 12600 times.
✗ Branch 1 not taken.
12600 if(!p_igetl(&(tempffc.initd[q]),f))
17074 return qe_invalid;
17075 12600 }
17076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1575 times.
1575 if(!p_getc(&(tempbyte),f))
17077 return qe_invalid;
17078 1575 tempffc.inita[0]=tempbyte*10000;
17079
17080
1/2
✓ Branch 0 taken 1575 times.
✗ Branch 1 not taken.
1575 if(!p_getc(&(tempbyte),f))
17081 return qe_invalid;
17082 1575 tempffc.inita[1]=tempbyte*10000;
17083 1575 }
17084
2/2
✓ Branch 0 taken 773579 times.
✓ Branch 1 taken 6109 times.
779688 for(word m = numffc; m < MAXFFCS; ++m)
17085 {
17086 773579 temp_mapscr->ffcs[m].clear();
17087 773579 }
17088 //END FFC
17089 }
17090 253285 return 0;
17091 263904 }
17092
17093
17094 130 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17095 {
17096 130 int32_t scr=0;
17097
17098 130 word version=0;
17099 dword dummy;
17100 int32_t screens_to_read;
17101
17102 130 mapscr temp_mapscr;
17103 zcmap temp_map;
17104 word temp_map_count;
17105 dword section_size;
17106
17107
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17108 {
17109 4 screens_to_read=MAPSCRS192b136;
17110 4 }
17111 else
17112 {
17113 126 screens_to_read=MAPSCRS;
17114 }
17115
17116
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(Header->zelda_version > 0x192)
17117 {
17118 //section version info
17119
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&version,f))
17120 {
17121 return qe_invalid;
17122 }
17123
17124 126 FFCore.quest_format[vMaps] = version;
17125
17126 //al_trace("Maps version %d\n", version);
17127
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&dummy,f))
17128 {
17129 return qe_invalid;
17130 }
17131
17132 //section size
17133
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&section_size,f))
17134 {
17135 return qe_invalid;
17136 }
17137
17138 //finally... section data
17139
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&temp_map_count,f))
17140 {
17141 return 5;
17142 }
17143 126 }
17144 else
17145 {
17146 4 temp_map_count=map_count;
17147 }
17148
17149
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 130 times.
130 if (!(temp_map_count >= 0 && temp_map_count <= MAXMAPS2))
17150 {
17151 return qe_invalid;
17152 }
17153
17154 130 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17155 130 TheMaps.resize(_mapsSize);
17156 130 map_autolayers.clear();
17157 130 map_autolayers.resize(temp_map_count*6);
17158
17159
2/2
✓ Branch 0 taken 265064 times.
✓ Branch 1 taken 130 times.
265194 for(int32_t i(0); i<_mapsSize; i++)
17160 265064 TheMaps[i].zero_memory();
17161
17162 130 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17163
17164 130 temp_mapscr.zero_memory();
17165
17166 { //Is this stuff even needed anymore? Is it used at all? -Em
17167 130 memset(&temp_map, 0, sizeof(zcmap));
17168 130 temp_map.scrResWidth = 256;
17169 130 temp_map.scrResHeight = 224;
17170 130 temp_map.tileWidth = 16;
17171 130 temp_map.tileHeight = 11;
17172 130 temp_map.viewWidth = 256;
17173 130 temp_map.viewHeight = 176;
17174 130 temp_map.viewX = 0;
17175 130 temp_map.viewY = 64;
17176 130 temp_map.subaWidth = 256;
17177 130 temp_map.subaHeight = 168;
17178 130 temp_map.subaTrans = false;
17179 130 temp_map.subpWidth = 256;
17180 130 temp_map.subpHeight = 56;
17181 130 temp_map.subpTrans = false;
17182 }
17183
4/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 1949 times.
✓ Branch 2 taken 1949 times.
✓ Branch 3 taken 130 times.
2079 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17184 {
17185 //!TODO Trim fully
17186 1949 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17187
17188 1949 byte valid=1;
17189
2/2
✓ Branch 0 taken 1819 times.
✓ Branch 1 taken 130 times.
1949 if(version > 22)
17190 {
17191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(!p_getc(&valid,f))
17192 return qe_invalid;
17193 130 }
17194
4/4
✓ Branch 0 taken 1942 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 1886 times.
✓ Branch 3 taken 56 times.
1949 if(valid && version > 25)
17195 {
17196
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 56 times.
392 for(int q = 0; q < 6; ++q)
17197 {
17198
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_igetw(&map_autolayers[i*6+q],f))
17199 return qe_invalid;
17200 336 }
17201 56 }
17202
2/2
✓ Branch 0 taken 264856 times.
✓ Branch 1 taken 1949 times.
266805 for(int32_t j=0; j<screens_to_read; j++)
17203 {
17204 264856 scr=i*MAPSCRS+j;
17205 264856 clear_screen(&temp_mapscr);
17206
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 263904 times.
264856 if(valid)
17207 263904 readmapscreen(f, Header, &temp_mapscr, &temp_map, version, scr);
17208
17209 264856 TheMaps[scr] = temp_mapscr;
17210 264856 }
17211
17212
3/6
✓ Branch 0 taken 1897 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1897 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1949 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17213 {
17214 52 int32_t index = (i*MAPSCRS+132);
17215
17216 52 TheMaps[index]=TheMaps[index-1];
17217
17218 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17219 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17220 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17221
17222
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
208 for(int32_t j=133; j<MAPSCRS; j++)
17223 {
17224 156 scr=i*MAPSCRS+j;
17225
17226 156 TheMaps[scr].zero_memory();
17227 156 TheMaps[scr].valid = mVERSION;
17228 156 TheMaps[scr].screen_midi = -1;
17229 156 TheMaps[scr].csensitive = 1;
17230 156 }
17231 52 }
17232
17233
3/6
✓ Branch 0 taken 1897 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1897 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1949 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17234 {
17235
2/2
✓ Branch 0 taken 7072 times.
✓ Branch 1 taken 52 times.
7124 for(int32_t j=0; j<MAPSCRS; j++)
17236 {
17237 7072 scr=i*MAPSCRS+j;
17238 7072 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17239
17240
2/2
✓ Branch 0 taken 905216 times.
✓ Branch 1 taken 7072 times.
912288 for(int32_t k=0; k<128; k++)
17241 {
17242 905216 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17243 905216 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17244 905216 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17245 905216 }
17246 7072 }
17247 52 }
17248 1949 }
17249 130 map_count = temp_map_count;
17250 130 clear_screen(&temp_mapscr);
17251 130 return 0;
17252 130 }
17253
17254
17255 1099561 void update_combo(newcombo& cmb, word section_version)
17256 {
17257
2/2
✓ Branch 0 taken 158844 times.
✓ Branch 1 taken 940717 times.
1099561 if(section_version < 40)
17258 {
17259
3/3
✓ Branch 0 taken 1389 times.
✓ Branch 1 taken 14209 times.
✓ Branch 2 taken 925119 times.
940717 switch(cmb.type)
17260 {
17261 case cWATER: case cSHALLOWWATER:
17262 14209 cmb.attribytes[6] = iwRipples;
17263 14209 break;
17264 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17265 1389 cmb.attribytes[6] = iwTallGrass;
17266 1389 break;
17267 }
17268 940717 }
17269 1099561 }
17270 95 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17271 {
17272 95 reset_combo_animations();
17273 95 reset_combo_animations2();
17274
17275 95 init_combo_classes();
17276
17277 // combos
17278 95 word combos_used=0;
17279 int32_t dummy;
17280 byte padding;
17281 95 newcombo temp_combo;
17282 //word section_cversion=0;
17283
17284
2/2
✓ Branch 0 taken 6201600 times.
✓ Branch 1 taken 95 times.
6201695 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17285
1/2
✓ Branch 0 taken 6201600 times.
✗ Branch 1 not taken.
6201600 combobuf[q].clear();
17286
17287 // if(version > 0x192)
17288 // {
17289 // //section version info
17290 // if(!p_igetw(&section_version,f))
17291 // {
17292 // return qe_invalid;
17293 // }
17294
17295 // FFCore.quest_format[vCombos] = section_version;
17296
17297 // //al_trace("Combos version %d\n", section_version);
17298 // if(!p_igetw(&section_cversion,f))
17299 // {
17300 // return qe_invalid;
17301 // }
17302
17303 // //section size
17304 // if(!p_igetl(&dummy,f))
17305 // {
17306 // return qe_invalid;
17307 // }
17308 // }
17309
17310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if(version < 0x174)
17311 {
17312 combos_used=1024;
17313 }
17314
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
95 else if(version < 0x191)
17315 {
17316 4 combos_used=2048;
17317 4 }
17318 else
17319 {
17320
2/4
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91 times.
✗ Branch 3 not taken.
91 if(!p_igetw(&combos_used,f))
17321 {
17322 return qe_invalid;
17323 }
17324 }
17325
17326 //finally... section data
17327
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 873209 times.
873304 for(int32_t i=0; i<combos_used; i++)
17328 {
17329
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 temp_combo.clear();
17330
17331
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if ( section_version >= 11 )
17332 {
17333
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.tile,f))
17334 {
17335 return qe_invalid;
17336 }
17337 68884 }
17338 else
17339 {
17340
2/4
✓ Branch 0 taken 804325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804325 times.
✗ Branch 3 not taken.
804325 if(!p_igetw(&temp_combo.tile,f))
17341 {
17342 return qe_invalid;
17343 }
17344 }
17345 873209 temp_combo.o_tile = temp_combo.tile;
17346
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.flip,f))
17347 {
17348 return qe_invalid;
17349 }
17350
17351
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.walk,f))
17352 {
17353 return qe_invalid;
17354 }
17355
17356
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.type,f))
17357 {
17358 return qe_invalid;
17359 }
17360
17361
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.csets,f))
17362 {
17363 return qe_invalid;
17364 }
17365
17366
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 865017 times.
873209 if(version < 0x193)
17367 {
17368
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17369 return qe_invalid;
17370
17371
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17372 return qe_invalid;
17373
17374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
8192 if(version < 0x192)
17375 {
17376
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(version == 0x191)
17377 {
17378 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17379 {
17380 if(!p_getc(&padding,f))
17381 return qe_invalid;
17382 }
17383 }
17384 8192 }
17385 8192 }
17386
2/2
✓ Branch 0 taken 865017 times.
✓ Branch 1 taken 8192 times.
873209 if(version >= 0x192)
17387 {
17388
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.frames,f))
17389 return qe_invalid;
17390
17391
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.speed,f))
17392 return qe_invalid;
17393
17394
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_igetw(&temp_combo.nextcombo,f))
17395 return qe_invalid;
17396
17397
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.nextcset,f))
17398 return qe_invalid;
17399
17400 //Base flag
17401
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=3)
17402
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.flag,f))
17403 return qe_invalid;
17404
17405
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=4)
17406 {
17407
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanim,f))
17408 return qe_invalid;
17409
17410
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_igetw(&temp_combo.nexttimer,f))
17411 return qe_invalid;
17412 399183 }
17413
17414
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=5)
17415
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanimy,f))
17416 return qe_invalid;
17417
17418
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=6)
17419 {
17420
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.animflags,f))
17421 return qe_invalid;
17422
17423
1/2
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
399183 if(section_version == 6)
17424 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17425 399183 }
17426
17427
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=8) //combo Attributes[4] and userflags.
17428 {
17429
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 275536 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17430
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f))
17431 return qe_invalid;
17432
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f))
17433 return qe_invalid;
17434
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(section_version >= 20)
17435
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f))
17436 return qe_invalid;
17437 68884 }
17438
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=10) //combo trigger flags
17439 {
17440
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17441
2/4
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206652 times.
✗ Branch 3 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f))
17442 return qe_invalid;
17443 68884 }
17444
1/2
✓ Branch 0 taken 796133 times.
✗ Branch 1 not taken.
796133 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17445 {
17446 for ( int32_t q = 0; q < 2; q++ )
17447 if(!p_igetl(&temp_combo.triggerflags[q],f))
17448 return qe_invalid;
17449 }
17450
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 9)
17451
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f))
17452 return qe_invalid;
17453
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 22)
17454
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f))
17455 return qe_invalid;
17456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 24)
17457 {
17458 if(!p_getc(&temp_combo.triggeritem,f))
17459 return qe_invalid;
17460 if(!p_getc(&temp_combo.trigtimer,f))
17461 return qe_invalid;
17462 }
17463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 25)
17464 if(!p_getc(&temp_combo.trigsfx,f))
17465 return qe_invalid;
17466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 27)
17467 if(!p_igetl(&temp_combo.trigchange,f))
17468 return qe_invalid;
17469
17470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 29)
17471 {
17472 if(!p_igetw(&temp_combo.trigprox,f))
17473 return qe_invalid;
17474 if(!p_getc(&temp_combo.trigctr,f))
17475 return qe_invalid;
17476 if(!p_igetl(&temp_combo.trigctramnt,f))
17477 return qe_invalid;
17478 }
17479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 30)
17480 if(!p_getc(&temp_combo.triglbeam,f))
17481 return qe_invalid;
17482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 31)
17483 {
17484 if(!p_getc(&temp_combo.trigcschange,f))
17485 return qe_invalid;
17486 if(!p_igetw(&temp_combo.spawnitem,f))
17487 return qe_invalid;
17488 if(!p_igetw(&temp_combo.spawnenemy,f))
17489 return qe_invalid;
17490 if(!p_getc(&temp_combo.exstate,f))
17491 return qe_invalid;
17492 if(!p_igetl(&temp_combo.spawnip,f))
17493 return qe_invalid;
17494 if(!p_getc(&temp_combo.trigcopycat,f))
17495 return qe_invalid;
17496 }
17497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 32)
17498 if(!p_getc(&temp_combo.trigcooldown,f))
17499 return qe_invalid;
17500
17501
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=12) //combo label
17502 {
17503 char label[12];
17504 68884 label[11] = '\0';
17505
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 757724 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17506
2/4
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757724 times.
✗ Branch 3 not taken.
757724 if(!p_getc(&label[q],f))
17507 return qe_invalid;
17508
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 temp_combo.label = label;
17509 68884 }
17510
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=13) //attribytes[4]
17511
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
17512
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17513 68884 return qe_invalid;
17514 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17515 * This fixes a poor implementation of a ->next flag bug thing.
17516 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17517 * there was a version bump a few weeks before a change that broke stuff.
17518 */
17519
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68884 times.
865017 if (section_version >= 13 && section_version < 21)
17520 {
17521 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17522 }
17523 //combo scripts
17524
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=14)
17525 {
17526
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.script,f))
17527 return qe_invalid;
17528
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17529
2/4
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137768 times.
✗ Branch 3 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f))
17530 return qe_invalid;
17531 68884 }
17532 //al_trace("Read combo script data\n");
17533
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=15)
17534 {
17535
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17536
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17537
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17538
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17539 68884 }
17540
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=17) //attribytes[4]
17541 {
17542
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17543
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17544 return qe_invalid;
17545
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17546
2/4
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 551072 times.
✗ Branch 3 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f))
17547 return qe_invalid;
17548 68884 }
17549
17550
1/2
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
865017 if(version < 0x193)
17551 for(int32_t q=0; q<11; q++)
17552 if(!p_getc(&dummy,f))
17553 return qe_invalid;
17554 865017 }
17555
17556 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17557
3/6
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 474026 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399183 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
873209 if((version < 0x211)||((version == 0x211)&&(build<7)))
17558 {
17559
3/4
✓ Branch 0 taken 474026 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 465834 times.
✓ Branch 3 taken 8192 times.
474026 if(!get_qr(qr_NEWENEMYTILES))
17560 {
17561
1/5
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8192 switch(temp_combo.tile)
17562 {
17563 case 130:
17564 temp_combo.tile = 132;
17565 break;
17566
17567 case 131:
17568 temp_combo.tile = 133;
17569 break;
17570
17571 case 132:
17572 temp_combo.tile = 130;
17573 break;
17574
17575 case 133:
17576 temp_combo.tile = 131;
17577 break;
17578 }
17579 8192 }
17580 474026 }
17581
17582
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 15)
17583 804325 temp_combo.o_tile = temp_combo.tile;
17584
17585
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version<18) //upper bits for .walk
17586 804325 temp_combo.walk |= 0xF0;
17587
17588
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 19)
17589
2/2
✓ Branch 0 taken 3217300 times.
✓ Branch 1 taken 804325 times.
4021625 for(int32_t q = 0; q < 4; ++q)
17590 4021625 temp_combo.attributes[q] *= 10000L;
17591
17592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 23)
17593 {
17594
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 872825 times.
873209 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17595 {
17596 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17597 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17598 case cTRIGGERGENERIC: case cCSWITCH:
17599 384 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17600 384 }
17601 873209 }
17602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 25)
17603 {
17604
2/2
✓ Branch 0 taken 3061 times.
✓ Branch 1 taken 870148 times.
873209 switch(temp_combo.type)
17605 {
17606 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3061 times.
3061 if(!(temp_combo.usrflags & cflag3))
17608 3061 temp_combo.attribytes[3] = WAV_DOOR;
17609 3061 temp_combo.usrflags &= ~cflag3;
17610 3061 break;
17611 }
17612 873209 }
17613
17614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 26)
17615
2/2
✓ Branch 0 taken 872622 times.
✓ Branch 1 taken 587 times.
873796 if(temp_combo.type == cARMOS)
17616
1/2
✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
587 if(temp_combo.usrflags & cflag1)
17617 temp_combo.usrflags |= cflag3;
17618
17619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 27)
17620 {
17621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17622 temp_combo.trigchange = 1;
17623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17624 temp_combo.trigchange = -1;
17625 873209 else temp_combo.trigchange = 0;
17626 873209 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17627 873209 }
17628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 28)
17629 {
17630
2/2
✓ Branch 0 taken 1689 times.
✓ Branch 1 taken 871520 times.
873209 switch(temp_combo.type)
17631 {
17632 case cLOCKBLOCK: case cLOCKEDCHEST:
17633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1689 times.
1689 if(temp_combo.usrflags & cflag7)
17634 temp_combo.usrflags |= cflag8;
17635 1689 else temp_combo.usrflags &= ~cflag8;
17636 1689 temp_combo.usrflags &= ~cflag7;
17637 1689 break;
17638 }
17639
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 873140 times.
873209 switch(temp_combo.type)
17640 {
17641 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17642 69 temp_combo.attrishorts[2] = -1;
17643 69 temp_combo.usrflags |= cflag7;
17644 69 break;
17645 }
17646 873209 }
17647
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 20)
17648 {
17649 804325 temp_combo.genflags = 0;
17650
2/2
✓ Branch 0 taken 19291 times.
✓ Branch 1 taken 785034 times.
804325 switch(temp_combo.type)
17651 {
17652 case cPUSH_WAIT: case cPUSH_HEAVY:
17653 case cPUSH_HW: case cL_STATUE:
17654 case cR_STATUE: case cPUSH_HEAVY2:
17655 case cPUSH_HW2: case cPOUND:
17656 case cC_STATUE: case cMIRROR:
17657 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17658 case cMAGICPRISM: case cMAGICPRISM4:
17659 case cMAGICSPONGE: case cEYEBALL_A:
17660 case cEYEBALL_B: case cEYEBALL_4:
17661 case cBUSH: case cFLOWERS:
17662 case cLOCKBLOCK: case cLOCKBLOCK2:
17663 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17664 case cCHEST: case cCHEST2:
17665 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17666 case cBOSSCHEST: case cBOSSCHEST2:
17667 case cBUSHNEXT: case cBUSHTOUCHY:
17668 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17669 case cSIGNPOST: case cCSWITCHBLOCK:
17670 case cTORCH: case cTRIGGERGENERIC:
17671
1/2
✓ Branch 0 taken 19291 times.
✗ Branch 1 not taken.
19291 if(temp_combo.usrflags & cflag16)
17672 {
17673 temp_combo.genflags |= cflag1;
17674 temp_combo.usrflags &= ~cflag16;
17675 }
17676 19291 break;
17677 }
17678 804325 }
17679
17680 873209 update_combo(temp_combo, section_version);
17681
17682
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 if(i>=start_combo)
17683 {
17684
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 combobuf[i] = temp_combo;
17685 873209 }
17686 873209 }
17687
17688
3/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
95 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17689 {
17690
2/2
✓ Branch 0 taken 261120 times.
✓ Branch 1 taken 4 times.
261124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17691 {
17692
1/2
✓ Branch 0 taken 261120 times.
✗ Branch 1 not taken.
261120 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17693 {
17694 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17695 }
17696 261120 }
17697 4 }
17698
17699 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17700
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
95 if(version == 0x210 && !is_editor())
17701 {
17702
2/2
✓ Branch 0 taken 783360 times.
✓ Branch 1 taken 12 times.
783372 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17703
2/2
✓ Branch 0 taken 783351 times.
✓ Branch 1 taken 9 times.
783369 if(combobuf[tmpcounter].type == cLADDERONLY)
17704 9 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17705 12 }
17706
17707
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<7)
17708 {
17709
2/2
✓ Branch 0 taken 1044480 times.
✓ Branch 1 taken 16 times.
1044496 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17710 {
17711
6/9
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1043840 times.
1044480 switch(combobuf[tmpcounter].type)
17712 {
17713 case cSLASH:
17714 250 combobuf[tmpcounter].type=cSLASHTOUCHY;
17715 250 break;
17716
17717 case cSLASHITEM:
17718 174 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
17719 174 break;
17720
17721 case cBUSH:
17722 126 combobuf[tmpcounter].type=cBUSHTOUCHY;
17723 126 break;
17724
17725 case cFLOWERS:
17726 45 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
17727 45 break;
17728
17729 case cTALLGRASS:
17730 45 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
17731 45 break;
17732
17733 case cSLASHNEXT:
17734 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
17735 break;
17736
17737 case cSLASHNEXTITEM:
17738 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
17739 break;
17740
17741 case cBUSHNEXT:
17742 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
17743 break;
17744 }
17745 1044480 }
17746 16 }
17747
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 93 times.
95 if (section_version < 16)
17748 {
17749
2/2
✓ Branch 0 taken 6071040 times.
✓ Branch 1 taken 93 times.
6071133 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17750 {
17751
2/2
✓ Branch 0 taken 6062986 times.
✓ Branch 1 taken 8054 times.
6071040 if (combobuf[tmpcounter].type == cWATER)
17752 {
17753 8054 combobuf[tmpcounter].attributes[0] = 40000L;
17754 8054 }
17755 6071040 }
17756 93 }
17757
3/4
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 1 times.
95 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
17758 {
17759 1 combobuf[0].walk = 0xF0;
17760 1 combobuf[0].type = 0;
17761 1 combobuf[0].flag = 0;
17762 1 }
17763
17764 //Now for the new combo alias reset
17765
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<2)
17766 {
17767
2/2
✓ Branch 0 taken 131072 times.
✓ Branch 1 taken 16 times.
131088 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
17768 {
17769 131072 combo_aliases[j].width = 0;
17770 131072 combo_aliases[j].height = 0;
17771 131072 combo_aliases[j].layermask = 0;
17772
17773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].combos != NULL)
17774 {
17775
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 delete[] combo_aliases[j].combos;
17776 131072 }
17777
17778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].csets != NULL)
17779 {
17780
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 delete[] combo_aliases[j].csets;
17781 131072 }
17782
17783
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].combos = new word[1];
17784
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].csets = new byte[1];
17785 131072 combo_aliases[j].combos[0] = 0;
17786 131072 combo_aliases[j].csets[0] = 0;
17787 131072 }
17788 16 }
17789
17790
17791
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations();
17792
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations2();
17793 95 return 0;
17794 95 }
17795 226352 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
17796 {
17797 byte combo_has_flags;
17798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226352 times.
226352 if(!p_getc(&combo_has_flags,f))
17799 return qe_invalid;
17800
17801 226352 temp_combo.clear();
17802
2/2
✓ Branch 0 taken 150963 times.
✓ Branch 1 taken 75389 times.
226352 if(combo_has_flags)
17803 {
17804
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 75386 times.
75389 if(combo_has_flags&CHAS_BASIC)
17805 {
17806
1/2
✓ Branch 0 taken 75386 times.
✗ Branch 1 not taken.
75386 if(!p_igetl(&temp_combo.tile,f))
17807 {
17808 return qe_invalid;
17809 }
17810 75386 temp_combo.o_tile = temp_combo.tile;
17811
17812
1/2
✓ Branch 0 taken 75386 times.
✗ Branch 1 not taken.
75386 if(!p_getc(&temp_combo.flip,f))
17813 {
17814 return qe_invalid;
17815 }
17816
17817
1/2
✓ Branch 0 taken 75386 times.
✗ Branch 1 not taken.
75386 if(!p_getc(&temp_combo.walk,f))
17818 {
17819 return qe_invalid;
17820 }
17821
17822
1/2
✓ Branch 0 taken 75386 times.
✗ Branch 1 not taken.
75386 if(!p_getc(&temp_combo.type,f))
17823 {
17824 return qe_invalid;
17825 }
17826
17827
1/2
✓ Branch 0 taken 75386 times.
✗ Branch 1 not taken.
75386 if(!p_getc(&temp_combo.flag,f))
17828 {
17829 return qe_invalid;
17830 }
17831
17832
1/2
✓ Branch 0 taken 75386 times.
✗ Branch 1 not taken.
75386 if(!p_getc(&temp_combo.csets,f))
17833 {
17834 return qe_invalid;
17835 }
17836 75386 }
17837
2/2
✓ Branch 0 taken 75366 times.
✓ Branch 1 taken 23 times.
75389 if(combo_has_flags&CHAS_SCRIPT)
17838 {
17839
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 15 times.
23 if (s_version>=41)
17840 {
17841 8 p_getcstr(&temp_combo.label, f);
17842 8 }
17843 else
17844 {
17845 char label[12];
17846 15 label[11] = '\0';
17847
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 15 times.
180 for ( int32_t q = 0; q < 11; q++ )
17848 {
17849
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_getc(&label[q],f))
17850 {
17851 return qe_invalid;
17852 }
17853 165 }
17854 15 temp_combo.label = label;
17855 }
17856
17857
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
17858 23 auto initd_count = s_version >= 43 ? 8 : 2;
17859
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 23 times.
117 for ( int32_t q = 0; q < initd_count; q++ )
17860 {
17861
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if(!p_igetl(&temp_combo.initd[q],f))
17862 {
17863 return qe_invalid;
17864 }
17865 94 }
17866 23 }
17867
2/2
✓ Branch 0 taken 54890 times.
✓ Branch 1 taken 20499 times.
75389 if(combo_has_flags&CHAS_ANIM)
17868 {
17869
1/2
✓ Branch 0 taken 20499 times.
✗ Branch 1 not taken.
20499 if(!p_getc(&temp_combo.frames,f))
17870 {
17871 return qe_invalid;
17872 }
17873
17874
1/2
✓ Branch 0 taken 20499 times.
✗ Branch 1 not taken.
20499 if(!p_getc(&temp_combo.speed,f))
17875 {
17876 return qe_invalid;
17877 }
17878
17879
1/2
✓ Branch 0 taken 20499 times.
✗ Branch 1 not taken.
20499 if(!p_igetw(&temp_combo.nextcombo,f))
17880 {
17881 return qe_invalid;
17882 }
17883
17884
1/2
✓ Branch 0 taken 20499 times.
✗ Branch 1 not taken.
20499 if(!p_getc(&temp_combo.nextcset,f))
17885 {
17886 return qe_invalid;
17887 }
17888
17889
1/2
✓ Branch 0 taken 20499 times.
✗ Branch 1 not taken.
20499 if(!p_getc(&temp_combo.skipanim,f))
17890 {
17891 return qe_invalid;
17892 }
17893
17894
1/2
✓ Branch 0 taken 20499 times.
✗ Branch 1 not taken.
20499 if(!p_getc(&temp_combo.skipanimy,f))
17895 {
17896 return qe_invalid;
17897 }
17898
17899
1/2
✓ Branch 0 taken 20499 times.
✗ Branch 1 not taken.
20499 if(!p_getc(&temp_combo.animflags,f))
17900 {
17901 return qe_invalid;
17902 }
17903 20499 }
17904
2/2
✓ Branch 0 taken 66263 times.
✓ Branch 1 taken 9126 times.
75389 if(combo_has_flags&CHAS_ATTRIB)
17905 {
17906
2/2
✓ Branch 0 taken 36504 times.
✓ Branch 1 taken 9126 times.
45630 for ( int32_t q = 0; q < 4; q++ )
17907 {
17908
1/2
✓ Branch 0 taken 36504 times.
✗ Branch 1 not taken.
36504 if(!p_igetl(&temp_combo.attributes[q],f))
17909 {
17910 return qe_invalid;
17911 }
17912 36504 }
17913
2/2
✓ Branch 0 taken 73008 times.
✓ Branch 1 taken 9126 times.
82134 for ( int32_t q = 0; q < 8; q++ )
17914 {
17915
1/2
✓ Branch 0 taken 73008 times.
✗ Branch 1 not taken.
73008 if(!p_getc(&temp_combo.attribytes[q],f))
17916 {
17917 return qe_invalid;
17918 }
17919 73008 }
17920
2/2
✓ Branch 0 taken 73008 times.
✓ Branch 1 taken 9126 times.
82134 for ( int32_t q = 0; q < 8; q++ )
17921 {
17922
1/2
✓ Branch 0 taken 73008 times.
✗ Branch 1 not taken.
73008 if(!p_igetw(&temp_combo.attrishorts[q],f))
17923 {
17924 return qe_invalid;
17925 }
17926 73008 }
17927 9126 }
17928
2/2
✓ Branch 0 taken 73145 times.
✓ Branch 1 taken 2244 times.
75389 if(combo_has_flags&CHAS_FLAG)
17929 {
17930
1/2
✓ Branch 0 taken 2244 times.
✗ Branch 1 not taken.
2244 if(!p_igetl(&temp_combo.usrflags,f))
17931 {
17932 return qe_invalid;
17933 }
17934
1/2
✓ Branch 0 taken 2244 times.
✗ Branch 1 not taken.
2244 if(!p_igetw(&temp_combo.genflags,f))
17935 {
17936 return qe_invalid;
17937 }
17938 2244 }
17939
2/2
✓ Branch 0 taken 74597 times.
✓ Branch 1 taken 792 times.
75389 if(combo_has_flags&CHAS_TRIG)
17940 {
17941 792 int numtrigs = s_version < 36 ? 3 : 6;
17942
2/2
✓ Branch 0 taken 4323 times.
✓ Branch 1 taken 792 times.
5115 for ( int32_t q = 0; q < numtrigs; q++ )
17943 {
17944
1/2
✓ Branch 0 taken 4323 times.
✗ Branch 1 not taken.
4323 if(!p_igetl(&temp_combo.triggerflags[q],f))
17945 {
17946 return qe_invalid;
17947 }
17948 4323 }
17949
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&temp_combo.triggerlevel,f))
17950 {
17951 return qe_invalid;
17952 }
17953
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&temp_combo.triggerbtn,f))
17954 {
17955 return qe_invalid;
17956 }
17957
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&temp_combo.triggeritem,f))
17958 {
17959 return qe_invalid;
17960 }
17961
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&temp_combo.trigtimer,f))
17962 {
17963 return qe_invalid;
17964 }
17965
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&temp_combo.trigsfx,f))
17966 {
17967 return qe_invalid;
17968 }
17969
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&temp_combo.trigchange,f))
17970 {
17971 return qe_invalid;
17972 }
17973
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetw(&temp_combo.trigprox,f))
17974 {
17975 return qe_invalid;
17976 }
17977
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&temp_combo.trigctr,f))
17978 {
17979 return qe_invalid;
17980 }
17981
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&temp_combo.trigctramnt,f))
17982 {
17983 return qe_invalid;
17984 }
17985
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&temp_combo.triglbeam,f))
17986 {
17987 return qe_invalid;
17988 }
17989
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&temp_combo.trigcschange,f))
17990 {
17991 return qe_invalid;
17992 }
17993
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetw(&temp_combo.spawnitem,f))
17994 {
17995 return qe_invalid;
17996 }
17997
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetw(&temp_combo.spawnenemy,f))
17998 {
17999 return qe_invalid;
18000 }
18001
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&temp_combo.exstate,f))
18002 {
18003 return qe_invalid;
18004 }
18005
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&temp_combo.spawnip,f))
18006 {
18007 return qe_invalid;
18008 }
18009
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&temp_combo.trigcopycat,f))
18010 {
18011 return qe_invalid;
18012 }
18013
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&temp_combo.trigcooldown,f))
18014 {
18015 return qe_invalid;
18016 }
18017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(s_version >= 35)
18018 {
18019
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetw(&temp_combo.prompt_cid,f))
18020 {
18021 return qe_invalid;
18022 }
18023
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&temp_combo.prompt_cs,f))
18024 {
18025 return qe_invalid;
18026 }
18027
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetw(&temp_combo.prompt_x,f))
18028 {
18029 return qe_invalid;
18030 }
18031
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetw(&temp_combo.prompt_y,f))
18032 {
18033 return qe_invalid;
18034 }
18035 792 }
18036
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 649 times.
792 if(s_version >= 36)
18037 {
18038
1/2
✓ Branch 0 taken 649 times.
✗ Branch 1 not taken.
649 if(!p_getc(&temp_combo.trig_lstate,f))
18039 {
18040 return qe_invalid;
18041 }
18042
1/2
✓ Branch 0 taken 649 times.
✗ Branch 1 not taken.
649 if(!p_getc(&temp_combo.trig_gstate,f))
18043 {
18044 return qe_invalid;
18045 }
18046
1/2
✓ Branch 0 taken 649 times.
✗ Branch 1 not taken.
649 if(!p_igetl(&temp_combo.trig_statetime,f))
18047 {
18048 return qe_invalid;
18049 }
18050 649 }
18051
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 649 times.
792 if(s_version >= 37)
18052 {
18053
1/2
✓ Branch 0 taken 649 times.
✗ Branch 1 not taken.
649 if(!p_igetw(&temp_combo.trig_genscr,f))
18054 {
18055 return qe_invalid;
18056 }
18057 649 }
18058
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 575 times.
792 if(s_version >= 38)
18059 {
18060
1/2
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
575 if(!p_getc(&temp_combo.trig_group,f))
18061 {
18062 return qe_invalid;
18063 }
18064
1/2
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
575 if(!p_igetw(&temp_combo.trig_group_val,f))
18065 {
18066 return qe_invalid;
18067 }
18068 575 }
18069 792 }
18070
2/2
✓ Branch 0 taken 75242 times.
✓ Branch 1 taken 147 times.
75389 if(combo_has_flags&CHAS_LIFT)
18071 {
18072
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_igetw(&temp_combo.liftcmb,f))
18073 return qe_invalid;
18074
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftcs,f))
18075 return qe_invalid;
18076
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_igetw(&temp_combo.liftundercmb,f))
18077 return qe_invalid;
18078
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftundercs,f))
18079 return qe_invalid;
18080
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftdmg,f))
18081 return qe_invalid;
18082
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftlvl,f))
18083 return qe_invalid;
18084
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftitm,f))
18085 return qe_invalid;
18086
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftflags,f))
18087 return qe_invalid;
18088
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftgfx,f))
18089 return qe_invalid;
18090
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftsprite,f))
18091 return qe_invalid;
18092
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftsfx,f))
18093 return qe_invalid;
18094
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18095 return qe_invalid;
18096
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftbreaksfx,f))
18097 return qe_invalid;
18098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(s_version >= 34)
18099 {
18100
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.lifthei,f))
18101 return qe_invalid;
18102
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.lifttime,f))
18103 return qe_invalid;
18104 147 }
18105
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 140 times.
147 if(s_version >= 39)
18106 {
18107
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&temp_combo.lift_parent_item,f))
18108 return qe_invalid;
18109 140 }
18110 147 }
18111
2/2
✓ Branch 0 taken 75293 times.
✓ Branch 1 taken 96 times.
75389 if(combo_has_flags&CHAS_GENERAL)
18112 {
18113
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.speed_mult,f))
18114 return qe_invalid;
18115
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.speed_div,f))
18116 return qe_invalid;
18117
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetzf(&temp_combo.speed_add,f))
18118 return qe_invalid;
18119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version >= 42)
18120 {
18121
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.sfx_appear,f))
18122 return qe_invalid;
18123
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.sfx_disappear,f))
18124 return qe_invalid;
18125
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.sfx_loop,f))
18126 return qe_invalid;
18127
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.sfx_walking,f))
18128 return qe_invalid;
18129
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.sfx_standing,f))
18130 return qe_invalid;
18131
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.spr_appear,f))
18132 return qe_invalid;
18133
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.spr_disappear,f))
18134 return qe_invalid;
18135
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.spr_walking,f))
18136 return qe_invalid;
18137
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.spr_standing,f))
18138 return qe_invalid;
18139 96 }
18140 96 }
18141 75389 }
18142 226352 update_combo(temp_combo, s_version);
18143 226352 return 0;
18144 226352 }
18145 130 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18146 {
18147 130 word section_version=0;
18148 130 word section_cversion=0;
18149 130 word combos_used=0;
18150 int32_t dummy;
18151 byte padding;
18152 130 newcombo temp_combo;
18153
18154
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 reset_combo_animations();
18155
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 reset_combo_animations2();
18156
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 init_combo_classes();
18157
18158
2/2
✓ Branch 0 taken 8486400 times.
✓ Branch 1 taken 130 times.
8486530 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18159
1/2
✓ Branch 0 taken 8486400 times.
✗ Branch 1 not taken.
8486400 combobuf[q].clear();
18160
18161
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(version > 0x192) //Version info
18162 {
18163
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&section_version,f))
18164 {
18165 return qe_invalid;
18166 }
18167 126 FFCore.quest_format[vCombos] = section_version;
18168
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&section_cversion,f))
18169 {
18170 return qe_invalid;
18171 }
18172
18173 //section size
18174
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetl(&dummy,f))
18175 {
18176 return qe_invalid;
18177 }
18178 126 }
18179
18180
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(section_version > 32) //Cleanup time!
18181 {
18182
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetw(&combos_used,f))
18183 {
18184 return qe_invalid;
18185 }
18186
2/2
✓ Branch 0 taken 226352 times.
✓ Branch 1 taken 35 times.
226387 for(int32_t i=0; i<combos_used; i++)
18187 {
18188
1/2
✓ Branch 0 taken 226352 times.
✗ Branch 1 not taken.
226352 auto ret = readcombo_loop(f,section_version,temp_combo);
18189
1/2
✓ Branch 0 taken 226352 times.
✗ Branch 1 not taken.
226352 if(ret) return ret;
18190
1/2
✓ Branch 0 taken 226352 times.
✗ Branch 1 not taken.
226352 if(i>=start_combo)
18191
1/2
✓ Branch 0 taken 226352 times.
✗ Branch 1 not taken.
226352 combobuf[i] = temp_combo;
18192 226352 }
18193 35 }
18194 else //Call the old function for all old versions
18195 {
18196
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18197
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 if(ret) return ret; //error, end read
18198 }
18199
18200
3/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 34 times.
130 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18201 {
18202 34 combobuf[0].walk = 0xF0;
18203 34 combobuf[0].type = 0;
18204 34 combobuf[0].flag = 0;
18205 34 }
18206
18207
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 setup_combo_animations();
18208
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 setup_combo_animations2();
18209 130 return 0;
18210 130 }
18211
18212 114 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18213 {
18214 //these are here to bypass compiler warnings about unused arguments
18215 114 Header=Header;
18216 114 version=version;
18217 114 build=build;
18218
18219 int32_t dummy;
18220 114 word sversion=0, c_sversion;
18221
18222 //section version info
18223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_igetw(&sversion,f))
18224 {
18225 return qe_invalid;
18226 }
18227
18228 114 FFCore.quest_format[vComboAliases] = sversion;
18229
18230 //al_trace("Combo aliases version %d\n", sversion);
18231
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&c_sversion,f))
18232 {
18233 return qe_invalid;
18234 }
18235
18236 //section size
18237
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&dummy,f))
18238 {
18239 return qe_invalid;
18240 }
18241
18242 114 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18243
18244
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 77 times.
114 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18245 {
18246 77 max_num_combo_aliases = MAX250COMBOALIASES;
18247 77 }
18248
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18249 {
18250 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18251 }
18252
18253
2/2
✓ Branch 0 taken 460800 times.
✓ Branch 1 taken 114 times.
460914 for(int32_t j=0; j<max_num_combo_aliases; j++)
18254 {
18255 byte width,height,mask,tempcset;
18256 int32_t count;
18257 word tempword;
18258 byte tempbyte;
18259
18260
1/2
✓ Branch 0 taken 460800 times.
✗ Branch 1 not taken.
460800 if(!p_igetw(&tempword,f))
18261 {
18262 return qe_invalid;
18263 }
18264
18265 460800 combo_aliases[j].combo = tempword;
18266
18267
1/2
✓ Branch 0 taken 460800 times.
✗ Branch 1 not taken.
460800 if(!p_getc(&tempbyte,f))
18268 {
18269 return qe_invalid;
18270 }
18271
18272 460800 combo_aliases[j].cset = tempbyte;
18273
18274
1/2
✓ Branch 0 taken 460800 times.
✗ Branch 1 not taken.
460800 if(!p_getc(&width,f))
18275 {
18276 return qe_invalid;
18277 }
18278
18279
1/2
✓ Branch 0 taken 460800 times.
✗ Branch 1 not taken.
460800 if(!p_getc(&height,f))
18280 {
18281 return qe_invalid;
18282 }
18283
18284
1/2
✓ Branch 0 taken 460800 times.
✗ Branch 1 not taken.
460800 if(!p_getc(&mask,f))
18285 {
18286 return qe_invalid;
18287 }
18288
18289 460800 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18290
18291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460800 times.
460800 if(combo_aliases[j].combos != NULL)
18292 {
18293
1/2
✓ Branch 0 taken 460800 times.
✗ Branch 1 not taken.
460800 delete[] combo_aliases[j].combos;
18294 460800 }
18295
18296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460800 times.
460800 if(combo_aliases[j].csets != NULL)
18297 {
18298
1/2
✓ Branch 0 taken 460800 times.
✗ Branch 1 not taken.
460800 delete[] combo_aliases[j].csets;
18299 460800 }
18300
18301 460800 combo_aliases[j].width = width;
18302 460800 combo_aliases[j].height = height;
18303 460800 combo_aliases[j].layermask = mask;
18304 460800 combo_aliases[j].combos = new word[count];
18305 460800 combo_aliases[j].csets = new byte[count];
18306
18307
2/2
✓ Branch 0 taken 472261 times.
✓ Branch 1 taken 460800 times.
933061 for(int32_t k=0; k<count; k++)
18308 {
18309
1/2
✓ Branch 0 taken 472261 times.
✗ Branch 1 not taken.
472261 if(!p_igetw(&tempword,f))
18310 {
18311 return qe_invalid;
18312 }
18313
18314 472261 combo_aliases[j].combos[k] = tempword;
18315 472261 }
18316
18317
2/2
✓ Branch 0 taken 472261 times.
✓ Branch 1 taken 460800 times.
933061 for(int32_t k=0; k<count; k++)
18318 {
18319
1/2
✓ Branch 0 taken 472261 times.
✗ Branch 1 not taken.
472261 if(!p_getc(&tempcset,f))
18320 {
18321 return qe_invalid;
18322 }
18323
18324 472261 combo_aliases[j].csets[k] = tempcset;
18325 472261 }
18326 460800 }
18327
18328 //Combo pools!
18329 114 word num_combo_pools = 0;
18330
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 35 times.
114 if(sversion >= 4)
18331 {
18332
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetw(&num_combo_pools,f))
18333 {
18334 return qe_invalid;
18335 }
18336 35 }
18337
18338
2/2
✓ Branch 0 taken 933888 times.
✓ Branch 1 taken 114 times.
934002 for(combo_pool& pool : combo_pools)
18339 {
18340 933888 pool.clear();
18341 }
18342
18343 114 combo_pool temp_cpool;
18344
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 114 times.
210 for(word cp = 0; cp < num_combo_pools; ++cp)
18345 {
18346 96 int32_t num_combos_in_pool = 0;
18347
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetl(&num_combos_in_pool,f))
18348 {
18349 return qe_invalid;
18350 }
18351
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(num_combos_in_pool < 1) continue; //nothing to read
18352
18353
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 temp_cpool.clear();
18354
18355 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18356
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 416 times.
512 for(auto q = 0; q < num_combos_in_pool; ++q)
18357 {
18358
2/4
✓ Branch 0 taken 416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 416 times.
✗ Branch 3 not taken.
416 if(!p_igetl(&cp_cid,f))
18359 {
18360 return qe_invalid;
18361 }
18362
2/4
✓ Branch 0 taken 416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 416 times.
✗ Branch 3 not taken.
416 if(!p_getc(&cp_cs,f))
18363 {
18364 return qe_invalid;
18365 }
18366
2/4
✓ Branch 0 taken 416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 416 times.
✗ Branch 3 not taken.
416 if(!p_igetw(&cp_quant,f))
18367 {
18368 return qe_invalid;
18369 }
18370
1/2
✓ Branch 0 taken 416 times.
✗ Branch 1 not taken.
416 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18371 416 }
18372
18373
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 combo_pools[cp] = temp_cpool;
18374 96 }
18375
18376 //Autocombos!
18377 114 word num_combo_autos = 0;
18378
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 106 times.
114 if (sversion >= 5)
18379 {
18380
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if (!p_igetw(&num_combo_autos, f))
18381 {
18382 return qe_invalid;
18383 }
18384 8 }
18385
18386
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 933888 times.
934002 for (combo_auto& cauto : combo_autos)
18387 {
18388
1/2
✓ Branch 0 taken 933888 times.
✗ Branch 1 not taken.
933888 cauto.clear(true);
18389 }
18390
18391
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 combo_auto temp_cauto;
18392
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 114 times.
130 for (word ca = 0; ca < num_combo_autos; ++ca)
18393 {
18394 byte type;
18395 int32_t display_cid, erase_cid;
18396 byte flags, arg;
18397
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if (!p_getc(&type, f))
18398 {
18399 return qe_invalid;
18400 }
18401
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if (!p_igetl(&display_cid, f))
18402 {
18403 return qe_invalid;
18404 }
18405
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if (!p_igetl(&erase_cid, f))
18406 {
18407 return qe_invalid;
18408 }
18409
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if (!p_getc(&flags, f))
18410 {
18411 return qe_invalid;
18412 }
18413
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if (!p_getc(&arg, f))
18414 {
18415 return qe_invalid;
18416 }
18417 16 int32_t num_combos_in_cauto = 0;
18418
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if (!p_igetl(&num_combos_in_cauto, f))
18419 {
18420 return qe_invalid;
18421 }
18422
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (num_combos_in_cauto < 1) continue; //nothing to read
18423
18424
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_cauto.clear();
18425
18426
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_cauto.setType(type);
18427
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_cauto.setDisplay(display_cid);
18428
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_cauto.setEraseCombo(erase_cid);
18429
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_cauto.setFlags(flags);
18430
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_cauto.setArg(arg);
18431
18432 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18433
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 176 times.
192 for (auto q = 0; q < num_combos_in_cauto; ++q)
18434 {
18435
2/4
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
176 if (!p_getc(&ca_ctype, f))
18436 {
18437 return qe_invalid;
18438 }
18439
2/4
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
176 if (!p_igetl(&ca_cid, f))
18440 {
18441 return qe_invalid;
18442 }
18443
1/2
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
176 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18444 176 }
18445
18446
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 combo_autos[ca] = temp_cauto;
18447 16 }
18448
18449 114 return 0;
18450 114 }
18451
18452 130 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18453 {
18454 //these are here to bypass compiler warnings about unused arguments
18455
18456 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18457 //Capitalized cause it'll save you a headache. -Deedee
18458 130 start_cset=start_cset;
18459 130 max_csets=max_csets;
18460 130 word s_version=0;
18461
18462 miscQdata temp_misc;
18463 130 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18464
18465 byte temp_colordata[48];
18466 char temp_palname[PALNAMESIZE];
18467
18468 int32_t dummy;
18469 word palcycles;
18470
18471
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(version > 0x192)
18472 {
18473 //section version info
18474
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_version,f))
18475 {
18476 return qe_invalid;
18477 }
18478
18479 126 FFCore.quest_format[vCSets] = s_version;
18480
18481 //al_trace("Color data version %d\n", s_version);
18482
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&dummy,f))
18483 {
18484 return qe_invalid;
18485 }
18486
18487 //section size
18488
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy,f))
18489 {
18490 return qe_invalid;
18491 }
18492 126 }
18493
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 37 times.
130 if (s_version < 5)
18494 {
18495
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
93 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18496
18497 //finally... section data
18498 93 int32_t q = 0;
18499 93 int32_t p = -15;
18500
2/2
✓ Branch 0 taken 22320 times.
✓ Branch 1 taken 93 times.
22413 for(int32_t i=0; i<oldpdTOTAL; ++i)
18501 {
18502 22320 memset(temp_colordata, 0, 48);
18503
18504
1/2
✓ Branch 0 taken 22320 times.
✗ Branch 1 not taken.
22320 if(!pfread(temp_colordata,48,f))
18505 {
18506 return qe_invalid;
18507 }
18508
18509 22320 memcpy(&colordata[q*48], temp_colordata, 48);
18510
18511 22320 ++q;
18512
8/8
✓ Branch 0 taken 20832 times.
✓ Branch 1 taken 1488 times.
✓ Branch 2 taken 1581 times.
✓ Branch 3 taken 19251 times.
✓ Branch 4 taken 186 times.
✓ Branch 5 taken 1395 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 178 times.
22320 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18513 {
18514
1/2
✓ Branch 0 taken 1573 times.
✗ Branch 1 not taken.
1573 if (s_version < 5) //Bumping up the size of level palettes
18515 {
18516 1573 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18517 1573 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18518 1573 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18519 1573 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18520 1573 q+=4;
18521 1573 }
18522 else
18523 {
18524 for(int m = 0; m < 4; ++m)
18525 {
18526 memset(temp_colordata, 0, 48);
18527 if(!pfread(temp_colordata,48,f))
18528 {
18529 return qe_invalid;
18530 }
18531 memcpy(&colordata[q*48], temp_colordata, 48);
18532 ++q;
18533 }
18534 }
18535 1573 }
18536 22320 ++p;
18537 22320 }
18538
18539
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
93 if(RealOldVerion)
18540 {
18541 4 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18542 4 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18543 4 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18544 4 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18545 4 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18546 4 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18547 4 }
18548 else
18549 {
18550 89 memset(temp_colordata, 0, 48);
18551
18552
2/2
✓ Branch 0 taken 278837 times.
✓ Branch 1 taken 89 times.
278926 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18553 {
18554
1/2
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
278837 if(!pfread(temp_colordata,48,f))
18555 {
18556 return qe_invalid;
18557 }
18558
18559 278837 memcpy(&colordata[q*48], temp_colordata, 48);
18560
18561 278837 ++q;
18562
7/8
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21449 times.
✓ Branch 3 taken 257388 times.
✓ Branch 4 taken 178 times.
✓ Branch 5 taken 21271 times.
✓ Branch 6 taken 154 times.
✓ Branch 7 taken 24 times.
278837 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18563 {
18564
1/2
✓ Branch 0 taken 21425 times.
✗ Branch 1 not taken.
21425 if (s_version < 5) //Bumping up the size of level palettes
18565 {
18566 21425 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18567 21425 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18568 21425 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18569 21425 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18570 21425 q+=4;
18571 21425 }
18572 else
18573 {
18574 for(int m = 0; m < 4; ++m)
18575 {
18576 memset(temp_colordata, 0, 48);
18577 if(!pfread(temp_colordata,48,f))
18578 {
18579 return qe_invalid;
18580 }
18581 memcpy(&colordata[q*48], temp_colordata, 48);
18582 ++q;
18583 }
18584 }
18585 21425 }
18586 278837 ++p;
18587 278837 }
18588
18589
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 77 times.
89 if(s_version < 4)
18590 {
18591 12 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18592 12 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18593 12 }
18594 else
18595 {
18596
2/2
✓ Branch 0 taken 256256 times.
✓ Branch 1 taken 77 times.
256333 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18597 {
18598
1/2
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
256256 if(!pfread(temp_colordata,48,f))
18599 {
18600 return qe_invalid;
18601 }
18602
18603 256256 memcpy(&colordata[q*48], temp_colordata, 48);
18604 256256 ++q;
18605
5/6
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19712 times.
✓ Branch 3 taken 236544 times.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 19558 times.
256256 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18606 {
18607
1/2
✓ Branch 0 taken 19558 times.
✗ Branch 1 not taken.
19558 if (s_version < 5) //Bumping up the size of level palettes
18608 {
18609 19558 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18610 19558 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18611 19558 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18612 19558 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18613 19558 q+=4;
18614 19558 }
18615 else
18616 {
18617 for(int m = 0; m < 4; ++m)
18618 {
18619 memset(temp_colordata, 0, 48);
18620 if(!pfread(temp_colordata,48,f))
18621 {
18622 return qe_invalid;
18623 }
18624 memcpy(&colordata[q*48], temp_colordata, 48);
18625 ++q;
18626 }
18627 }
18628 19558 }
18629 256256 ++p;
18630 256256 }
18631
18632 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18633 }
18634 }
18635 93 }
18636 else
18637 {
18638
2/2
✓ Branch 0 taken 323713 times.
✓ Branch 1 taken 37 times.
323750 for(int32_t i=0; i<pdTOTAL255; ++i)
18639 {
18640 323713 memset(temp_colordata, 0, 48);
18641
18642
1/2
✓ Branch 0 taken 323713 times.
✗ Branch 1 not taken.
323713 if(!pfread(temp_colordata,48,f))
18643 {
18644 return qe_invalid;
18645 }
18646
18647 323713 memcpy(&colordata[i*48], temp_colordata, 48);
18648 323713 }
18649 }
18650
18651
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((version < 0x192)||((version == 0x192)&&(build<76)))
18652 {
18653 4 init_palnames();
18654 4 }
18655 else
18656 {
18657 126 int32_t palnamestoread = 0;
18658
18659
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 114 times.
126 if(s_version < 3)
18660 12 palnamestoread = OLDMAXLEVELS;
18661 else
18662 114 palnamestoread = 512;
18663
18664
2/2
✓ Branch 0 taken 61440 times.
✓ Branch 1 taken 126 times.
61566 for(int32_t i=0; i<palnamestoread; ++i)
18665 {
18666 61440 memset(temp_palname, 0, PALNAMESIZE);
18667
18668
1/2
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
61440 if(!pfread(temp_palname,PALNAMESIZE,f))
18669 {
18670 return qe_invalid;
18671 }
18672
18673 61440 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18674 61440 }
18675
18676
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 126 times.
3198 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18677 {
18678 3072 memset(palnames[i], 0, PALNAMESIZE);
18679 3072 }
18680 }
18681
18682
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(version > 0x192)
18683 {
18684
2/2
✓ Branch 0 taken 32256 times.
✓ Branch 1 taken 126 times.
32382 for(int32_t i=0; i<256; i++)
18685 {
18686
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 32256 times.
129024 for(int32_t j=0; j<3; j++)
18687 {
18688 96768 temp_misc.cycles[i][j].first=0;
18689 96768 temp_misc.cycles[i][j].count=0;
18690 96768 temp_misc.cycles[i][j].speed=0;
18691 96768 }
18692 32256 }
18693
18694
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&palcycles,f))
18695 {
18696 return qe_invalid;
18697 }
18698
18699
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 if (!(palcycles >= 0 && palcycles <= NUM_PAL_CYCLES))
18700 {
18701 return qe_invalid;
18702 }
18703
18704
2/2
✓ Branch 0 taken 3576 times.
✓ Branch 1 taken 126 times.
3702 for(int32_t i=0; i<palcycles; i++)
18705 {
18706
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18707 {
18708
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18709 {
18710 return qe_invalid;
18711 }
18712 10728 }
18713
18714
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18715 {
18716
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18717 {
18718 return qe_invalid;
18719 }
18720 10728 }
18721
18722
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18723 {
18724
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18725 {
18726 return qe_invalid;
18727 }
18728 10728 }
18729 3576 }
18730
18731 126 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18732 126 }
18733
18734 130 return 0;
18735 130 }
18736
18737 130 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18738 {
18739 130 int32_t tiles_used=0;
18740 130 word section_version = 0;
18741 130 word section_cversion = 0;
18742 130 int32_t section_size= 0;
18743 130 byte *temp_tile = new byte[tilesize(tf32Bit)];
18744
18745 //Tile Expansion
18746 //if ( version >= 0x254 && build >= 41 )
18747
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
130 if (version < 0x254 && build < 41)
18748 {
18749 //al_trace("Build was < 41 when reading tiles\n");
18750 93 max_tiles = ZC250MAXTILES;
18751 93 }
18752
18753 //al_trace("Max Tiles: %d\n", max_tiles);
18754
18755
2/6
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 130 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
18756 {
18757 if(!init_tiles(true, Header))
18758 {
18759 al_trace("Unable to initialize tiles\n");
18760 }
18761
18762 delete[] temp_tile;
18763 temp_tile=NULL;
18764 return 0;
18765 }
18766 else
18767 {
18768
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(version > 0x192)
18769 {
18770 //section version info
18771
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&section_version,f))
18772 {
18773 delete[] temp_tile;
18774 return qe_invalid;
18775 }
18776
18777 126 FFCore.quest_format[vTiles] = section_version;
18778
18779
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&section_cversion,f))
18780 {
18781 delete[] temp_tile;
18782 return qe_invalid;
18783 }
18784
18785 //section size
18786
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&section_size,f))
18787 {
18788 delete[] temp_tile;
18789 return qe_invalid;
18790 }
18791 126 }
18792
18793 //if ( build < 41 )
18794 //{
18795 // tiles_used = ZC250MAXTILES;
18796 //}
18797
18798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(version < 0x174)
18799 {
18800 tiles_used=TILES_PER_PAGE*4;
18801 } //no expanded tile space
18802
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 else if(version < 0x191)
18803 {
18804 4 tiles_used=OLDMAXTILES;
18805 4 }
18806 else
18807 {
18808 //finally... section data
18809
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
126 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
18810 {
18811
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tiles_used,f))
18812 {
18813 delete[] temp_tile;
18814 return qe_invalid;
18815 }
18816 37 }
18817 else
18818 {
18819
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_igetw(&tiles_used,f))
18820 {
18821 delete[] temp_tile;
18822 return qe_invalid;
18823 }
18824 }
18825 }
18826
18827
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 tiles_used=zc_min(tiles_used, max_tiles);
18828
18829 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
18830 //if ( version < 0x254 && build < 41 )
18831
3/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if ( version < 0x254 || (version == 0x254 && build < 41) )
18832 //if ( build < 41 )
18833 {
18834
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
18835 93 }
18836 else //2.55
18837 {
18838
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
18839 }
18840
18841 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
18842
18843 //al_trace("tiles_used = %d\n", tiles_used);
18844
18845
2/2
✓ Branch 0 taken 3535794 times.
✓ Branch 1 taken 130 times.
3535924 for(int32_t i=0; i<tiles_used; ++i)
18846 {
18847 3535794 byte format=tf4Bit;
18848 3535794 memset(temp_tile, 0, tilesize(tf32Bit));
18849
18850
3/6
✓ Branch 0 taken 630780 times.
✓ Branch 1 taken 2905014 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 630780 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3535794 if((version>0x211)||((version==0x211)&&(build>4)))
18851 {
18852
1/2
✓ Branch 0 taken 2905014 times.
✗ Branch 1 not taken.
2905014 if(!p_getc(&format,f))
18853 {
18854 delete[] temp_tile;
18855 return qe_invalid;
18856 }
18857 2905014 }
18858
4/4
✓ Branch 0 taken 1355460 times.
✓ Branch 1 taken 2180334 times.
✓ Branch 2 taken 627149 times.
✓ Branch 3 taken 728311 times.
3535794 if(section_version > 2 && !format)
18859 {
18860 728311 reset_tile(buf,start_tile+i,tf4Bit);
18861 728311 continue;
18862 }
18863
18864
1/2
✓ Branch 0 taken 2807483 times.
✗ Branch 1 not taken.
2807483 if(!pfread(temp_tile,tilesize(format),f))
18865 {
18866 delete[] temp_tile;
18867 return qe_invalid;
18868 }
18869
18870 2807483 buf[start_tile+i].format=format;
18871
18872
1/2
✓ Branch 0 taken 2807483 times.
✗ Branch 1 not taken.
2807483 if(buf[start_tile+i].data)
18873 {
18874 2807483 free(buf[start_tile+i].data);
18875 2807483 buf[start_tile+i].data=NULL;
18876 2807483 }
18877
18878 2807483 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
18879 2807483 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
18880 2807483 }
18881 }
18882
18883
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
18884 {
18885 //al_trace("Writing blank tile data to new tiles for build < 41\n");
18886
2/2
✓ Branch 0 taken 13855140 times.
✓ Branch 1 taken 93 times.
13855233 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
18887 {
18888
18889 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
18890 13855140 reset_tile(buf,q,tf4Bit);
18891
18892
18893 /*
18894
18895 byte tempbyte;
18896 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18897 {
18898 tempbyte=buf[ZC250MAXTILES-1].data[i];
18899 buf[q].data[i] = tempbyte;
18900 }
18901 //int32_t temp = tempbyte=buf[130].data[i];
18902 //buf[q].data = buf[ZC250MAXTILES-1].data;
18903 */
18904 //reset_tile(buf,q,tf4Bit);
18905 13855140 }
18906
18907 93 }
18908
18909
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
18910 {
18911
2/2
✓ Branch 0 taken 4121646 times.
✓ Branch 1 taken 93 times.
4121739 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
18912 {
18913 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
18914 4121646 reset_tile(buf,i,tf4Bit);
18915 4121646 }
18916 93 }
18917 else
18918 {
18919
2/2
✓ Branch 0 taken 6372420 times.
✓ Branch 1 taken 37 times.
6372457 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
18920 {
18921 //al_trace("Resetting tiles for build 41+\n");
18922 6372420 reset_tile(buf,i,tf4Bit);
18923 6372420 }
18924 }
18925
18926
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
18927 {
18928
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_qr(qr_BSZELDA)) //
18929 {
18930 byte tempbyte;
18931 int32_t floattile=wpnsbuf[iwSwim].tile;
18932
18933 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
18934 {
18935 tempbyte=buf[23].data[i];
18936 buf[23].data[i]=buf[24].data[i];
18937 buf[24].data[i]=buf[25].data[i];
18938 buf[25].data[i]=buf[26].data[i];
18939 buf[26].data[i]=tempbyte;
18940 }
18941 //swim tiles are out of order, too, but nobody cared? -Z
18942 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18943 {
18944 tempbyte=buf[floattile+11].data[i];
18945 buf[floattile+11].data[i]=buf[floattile+12].data[i];
18946 buf[floattile+12].data[i]=tempbyte;
18947 }
18948 }
18949 4 }
18950
18951
3/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
18952 {
18953
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(!get_qr(qr_NEWENEMYTILES))
18954 {
18955 byte tempbyte;
18956
18957
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18958 {
18959 512 tempbyte=buf[130].data[i];
18960 512 buf[130].data[i]=buf[132].data[i];
18961 512 buf[132].data[i]=tempbyte;
18962
18963 512 tempbyte=buf[131].data[i];
18964 512 buf[131].data[i]=buf[133].data[i];
18965 512 buf[133].data[i]=tempbyte;
18966 512 }
18967 4 }
18968 16 }
18969
18970 130 al_trace("Registering blank tiles\n");
18971 130 register_blank_tiles();
18972
18973 //memset(temp_tile, 0, tilesize(tf32Bit));
18974
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 delete[] temp_tile;
18975 130 temp_tile=NULL;
18976 130 return 0;
18977 130 }
18978
18979 130 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
18980 {
18981 130 byte *mf=midi_flags;
18982 int32_t dummy;
18983 word dummy2;
18984 // zcmidi_ temp_midi;
18985 int32_t tunes_to_read;
18986 130 int32_t tune_count=0;
18987 130 word section_version=0;
18988 130 zctune temp;
18989
18990
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version < 0x193)
18991 {
18992 // mf=Header->data_flags+ZQ_MIDIS2;
18993
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
18994 {
18995 4 tunes_to_read=MAXCUSTOMMIDIS192b177;
18996 4 }
18997 else
18998 {
18999 tunes_to_read=MAXCUSTOMTUNES;
19000 }
19001 4 }
19002 else
19003 {
19004 //section version info
19005
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&section_version,f))
19006 {
19007 return qe_invalid;
19008 }
19009
19010 126 FFCore.quest_format[vMIDIs] = section_version;
19011
19012 //al_trace("Tunes version %d\n", section_version);
19013
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&dummy2,f))
19014 {
19015 return qe_invalid;
19016 }
19017
19018 //section size
19019
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy,f))
19020 {
19021 return qe_invalid;
19022 }
19023
19024 //finally... section data
19025
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!pfread(midi_flags,sizeof(midi_flags),f))
19026 {
19027 return qe_invalid;
19028 }
19029
19030 126 tunes_to_read=MAXCUSTOMTUNES;
19031 }
19032
19033
2/2
✓ Branch 0 taken 32760 times.
✓ Branch 1 taken 130 times.
32890 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19034 {
19035
2/2
✓ Branch 0 taken 30457 times.
✓ Branch 1 taken 2303 times.
32760 if(get_bit(mf, i))
19036 {
19037 2303 ++tune_count;
19038 2303 }
19039 32760 }
19040
19041 130 reset_tunes(tunes); //reset_midis(midis);
19042
19043
2/2
✓ Branch 0 taken 31880 times.
✓ Branch 1 taken 130 times.
32010 for(int32_t i=0; i<tunes_to_read; i++)
19044 {
19045 31880 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19046
19047 31880 tunes[i].reset(); // reset_midi(midis+i);
19048
19049
2/2
✓ Branch 0 taken 29577 times.
✓ Branch 1 taken 2303 times.
31880 if(get_bit(mf,i))
19050 {
19051
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1586 times.
2303 if(section_version < 4)
19052 {
19053
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if(!pfread(&temp.title,sizeof(char)*20,f))
19054 {
19055 return qe_invalid;
19056 }
19057 717 }
19058 else
19059 {
19060
1/2
✓ Branch 0 taken 1586 times.
✗ Branch 1 not taken.
1586 if(!pfread(&temp.title,sizeof(temp.title),f))
19061 {
19062 return qe_invalid;
19063 }
19064 }
19065
19066
1/2
✓ Branch 0 taken 2303 times.
✗ Branch 1 not taken.
2303 if(!p_igetl(&temp.start,f))
19067 {
19068 return qe_invalid;
19069 }
19070
19071
1/2
✓ Branch 0 taken 2303 times.
✗ Branch 1 not taken.
2303 if(!p_igetl(&temp.loop_start,f))
19072 {
19073 return qe_invalid;
19074 }
19075
19076
1/2
✓ Branch 0 taken 2303 times.
✗ Branch 1 not taken.
2303 if(!p_igetl(&temp.loop_end,f))
19077 {
19078 return qe_invalid;
19079 }
19080
19081
1/2
✓ Branch 0 taken 2303 times.
✗ Branch 1 not taken.
2303 if(!p_igetw(&temp.loop,f))
19082 {
19083 return qe_invalid;
19084 }
19085
19086
1/2
✓ Branch 0 taken 2303 times.
✗ Branch 1 not taken.
2303 if(!p_igetw(&temp.volume,f))
19087 {
19088 return qe_invalid;
19089 }
19090
19091
2/2
✓ Branch 0 taken 2225 times.
✓ Branch 1 taken 78 times.
2303 if(Header->zelda_version < 0x193)
19092 {
19093
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(!p_igetl(&dummy,f))
19094 {
19095 return qe_invalid;
19096 }
19097 78 }
19098
19099
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1586 times.
2303 if(section_version >= 3)
19100 {
19101
1/2
✓ Branch 0 taken 1586 times.
✗ Branch 1 not taken.
1586 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19102 {
19103 return qe_invalid;
19104 }
19105 1586 }
19106
19107 2303 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19108
19109
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1586 times.
2303 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19110 {
19111 // old format - a midi is a midi
19112
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if((tunes[i].data=read_midi(f))==NULL)
19113 {
19114 return qe_invalid;
19115 }
19116
19117 //yes you can do this. Isn't the ? operator awesome? :)
19118 717 tunes[i].format = MFORMAT_MIDI;
19119 717 }
19120 else
19121 {
19122 // 'midi' could be midi or nes, gb, ... music
19123
1/2
✓ Branch 0 taken 1586 times.
✗ Branch 1 not taken.
1586 if(!pfread(&tunes[i].format,sizeof(tunes[i].format),f))
19124 {
19125 return qe_invalid;
19126 }
19127
19128 1586 zctune *ptr = &tunes[i];
19129
19130
1/2
✓ Branch 0 taken 1586 times.
✗ Branch 1 not taken.
1586 switch(temp.format)
19131 {
19132 case MFORMAT_MIDI:
19133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1586 times.
1586 if((ptr->data=read_midi(f))==NULL)
19134 {
19135 return qe_invalid;
19136 }
19137
19138 1586 break;
19139
19140 default:
19141 return qe_invalid;
19142 break;
19143 }
19144 }
19145 2303 }
19146 31880 }
19147
19148 130 return 0;
19149 130 }
19150
19151 130 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19152 {
19153 int32_t dummy;
19154 ZCHEATS tempzcheats;
19155 130 char temp_use_cheats=1;
19156 130 memset(&tempzcheats, 0, sizeof(tempzcheats));
19157 130 word s_version = 0;
19158
19159
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version > 0x192)
19160 {
19161 //section version info
19162
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_version,f))
19163 {
19164 return qe_invalid;
19165 }
19166
19167 126 FFCore.quest_format[vCheats] = s_version;
19168 //al_trace("Cheats version %d\n", dummy);
19169
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&dummy,f))
19170 {
19171 return qe_invalid;
19172 }
19173
19174 //section size
19175
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy,f))
19176 {
19177 return qe_invalid;
19178 }
19179
19180 //finally... section data
19181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(!p_getc(&temp_use_cheats,f))
19182 {
19183 return qe_invalid;
19184 }
19185 126 }
19186
19187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(Header->data_flags[ZQ_CHEATS2])
19188 {
19189
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(!p_igetl(&tempzcheats.flags,f))
19190 {
19191 return qe_invalid;
19192 }
19193
19194
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19195 {
19196 return qe_invalid;
19197 }
19198 130 }
19199
19200 130 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19201 130 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19202
19203 130 return 0;
19204 130 }
19205
19206 286 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
19207 {
19208 int32_t dummy;
19209 286 word s_version=0, s_cversion=0;
19210 byte padding;
19211
19212 286 zinitdata temp_zinit;
19213
19214 // Legacy item properties (now integrated into itemdata)
19215 byte sword_hearts[4];
19216 byte beam_hearts[4];
19217 286 byte beam_percent=0;
19218 word beam_power[4];
19219 286 byte hookshot_length=99;
19220 286 byte hookshot_links=100;
19221 286 byte longshot_length=99;
19222 286 byte longshot_links=100;
19223 286 byte moving_fairy_hearts=3;
19224 286 byte moving_fairy_heart_percent=0;
19225 286 byte stationary_fairy_hearts=3;
19226 286 byte stationary_fairy_heart_percent=0;
19227 286 byte moving_fairy_magic=0;
19228 286 byte moving_fairy_magic_percent=0;
19229 286 byte stationary_fairy_magic=0;
19230 286 byte stationary_fairy_magic_percent=0;
19231 286 byte blue_potion_hearts=100;
19232 286 byte blue_potion_heart_percent=1;
19233 286 byte red_potion_hearts=100;
19234 286 byte red_potion_heart_percent=1;
19235 286 byte blue_potion_magic=100;
19236 286 byte blue_potion_magic_percent=1;
19237 286 byte red_potion_magic=100;
19238 286 byte red_potion_magic_percent=1;
19239
19240
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 156 times.
286 temp_zinit.subscreen_style=get_qr(qr_COOLSCROLL)?1:0;
19241
19242
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(Header->zelda_version > 0x192)
19243 {
19244 //section version info
19245
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&s_version,f))
19246 {
19247 return qe_invalid;
19248 }
19249
19250 126 FFCore.quest_format[vInitData] = s_version;
19251
19252 //al_trace("Init data version %d\n", s_version);
19253
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&s_cversion,f))
19254 {
19255 return qe_invalid;
19256 }
19257
19258 //section size
19259
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetl(&dummy,f))
19260 {
19261 return qe_invalid;
19262 }
19263 126 }
19264
19265 /* HIGHLY UNORTHODOX UPDATING THING, by L
19266 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19267 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19268 * changing from 13 to 14.
19269 */
19270
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version < 14)
19271 16 fixpolsvoice=true;
19272
19273 /* End highly unorthodox updating thing */
19274
19275
5/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75 times.
✓ Branch 5 taken 39 times.
130 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19276 39 temp_zinit.jump_hero_layer_threshold=0;
19277
19278
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 114 times.
130 if(s_version >= 10)
19279 {
19280 char temp;
19281
19282 //new-style items
19283
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t j=0; j<256; j++)
19284 {
19285
2/4
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29184 times.
29184 if(!p_getc(&temp,f))
19286 return qe_invalid;
19287
19288 29184 temp_zinit.items[j] = (temp != 0);
19289 29184 }
19290 114 }
19291
19292
5/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 30 times.
130 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19293 {
19294 char temp;
19295
19296 //finally... section data
19297
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 30 times.
156 if((Header->zelda_version > 0x192)||
19298 //new only
19299 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19300 {
19301 //OLD-style items... sigh
19302
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 114 times.
126 if(s_version < 10)
19303 {
19304
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19305 {
19306 return qe_invalid;
19307 }
19308
19309 12 temp_zinit.items[iRaft]=(temp != 0);
19310
19311
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19312 {
19313 return qe_invalid;
19314 }
19315
19316 12 temp_zinit.items[iLadder]=(temp != 0);
19317
19318
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19319 {
19320 return qe_invalid;
19321 }
19322
19323 12 temp_zinit.items[iBook]=(temp != 0);
19324
19325
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19326 {
19327 return qe_invalid;
19328 }
19329
19330 12 temp_zinit.items[iMKey]=(temp!=0);
19331
19332
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19333 {
19334 return qe_invalid;
19335 }
19336
19337 12 temp_zinit.items[iFlippers]=(temp != 0);
19338
19339
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19340 {
19341 return qe_invalid;
19342 }
19343
19344 12 temp_zinit.items[iBoots]=(temp!=0);
19345 12 }
19346 126 }
19347
19348
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 142 times.
156 if(s_version < 10)
19349 {
19350 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19351
19352
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempring,f))
19353 {
19354 return qe_invalid;
19355 }
19356
19357
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempsword,f))
19358 {
19359 return qe_invalid;
19360 }
19361
19362
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempshield,f))
19363 {
19364 return qe_invalid;
19365 }
19366
19367
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempwallet,f))
19368 {
19369 return qe_invalid;
19370 }
19371
19372
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbracelet,f))
19373 {
19374 return qe_invalid;
19375 }
19376
19377
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempamulet,f))
19378 {
19379 return qe_invalid;
19380 }
19381
19382
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbow,f))
19383 {
19384 return qe_invalid;
19385 }
19386
19387 //old only
19388
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19389 {
19390 tempring=(tempring)?(1<<(tempring-1)):0;
19391 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19392 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19393 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19394 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19395 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19396 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19397 }
19398
19399 //rings start at level 2... wtf
19400 //account for this -DD
19401 12 tempring <<= 1;
19402
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19403
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19404
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19405
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19406 //bracelet ALSO starts at level 2 :-( -DD
19407 12 tempbracelet<<=1;
19408
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19409
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19410
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19411
19412 //new only
19413
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build>173))
19414 {
19415 for(int32_t q=0; q<32; q++)
19416 {
19417 if(!p_getc(&padding,f))
19418 {
19419 return qe_invalid;
19420 }
19421 }
19422 }
19423
19424 char tempcandle, tempboomerang, temparrow, tempwhistle;
19425
19426
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempcandle,f))
19427 {
19428 return qe_invalid;
19429 }
19430
19431
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempboomerang,f))
19432 {
19433 return qe_invalid;
19434 }
19435
19436
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temparrow,f))
19437 {
19438 return qe_invalid;
19439 }
19440
19441
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19442 {
19443 return qe_invalid;
19444 }
19445
19446
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19447
19448
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempwhistle,f))
19449 {
19450 return qe_invalid;
19451 }
19452
19453 //old only
19454
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19455 {
19456 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19457 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19458 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19459 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19460 }
19461
19462
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19463
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19464
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19465
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19466 //What about the potion...?
19467
19468 12 }
19469
19470
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 65 times.
154 if(s_version < 29)
19471 {
19472 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19473 //to jab out my eye...
19474
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19475 return qe_invalid;
19476 89 temp_zinit.bombs = padding;
19477
19478
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19479 return qe_invalid;
19480 89 temp_zinit.super_bombs = padding;
19481 89 }
19482
19483 //Back to more OLD item code
19484
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
154 if(s_version < 10)
19485 {
19486
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version > 0x192)||
19487 //new only
19488 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19489 {
19490
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19491 {
19492 return qe_invalid;
19493 }
19494
19495
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19496
19497
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19498 {
19499 return qe_invalid;
19500 }
19501
19502
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19503
19504
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19505 {
19506 return qe_invalid;
19507 }
19508
19509
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19510
19511
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19512 {
19513 return qe_invalid;
19514 }
19515
19516
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19517
19518
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19519 {
19520 return qe_invalid;
19521 }
19522
19523
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19524
19525
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19526 {
19527 return qe_invalid;
19528 }
19529
19530
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19531
19532
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19533 {
19534 return qe_invalid;
19535 }
19536
19537
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19538
19539
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19540 {
19541 return qe_invalid;
19542 }
19543
19544
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19545
19546
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19547 {
19548 return qe_invalid;
19549 }
19550
19551
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19552
19553
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19554 {
19555 return qe_invalid;
19556 }
19557
19558
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(Header->zelda_version == 0x192)
19559 {
19560 for(int32_t q=0; q<32; q++)
19561 {
19562 if(!p_getc(&padding,f))
19563 {
19564 return qe_invalid;
19565 }
19566 }
19567 }
19568 12 }
19569 12 }
19570
19571 //old only
19572
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
24 if((Header->zelda_version == 0x192)&&(Header->build<174))
19573 {
19574 byte equipment, items; //bit flags
19575
19576 if(!p_getc(&equipment,f))
19577 {
19578 return qe_invalid;
19579 }
19580
19581 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19582 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19583 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19584 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19585 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19586 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19587
19588
19589 if(!p_getc(&items,f))
19590 {
19591 return qe_invalid;
19592 }
19593
19594 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
19595 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
19596 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
19597 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
19598 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
19599 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
19600 }
19601
19602 if(!p_getc(&temp_zinit.hc,f))
19603 {
19604 return qe_invalid;
19605 }
19606
19607
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 114 times.
126 if(s_version < 14)
19608 {
19609 byte temphp;
19610
19611
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temphp,f))
19612 {
19613 return qe_invalid;
19614 }
19615
19616 12 temp_zinit.start_heart=temphp;
19617
19618
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temphp,f))
19619 {
19620 return qe_invalid;
19621 }
19622
19623 12 temp_zinit.cont_heart=temphp;
19624 12 }
19625 else
19626 {
19627
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_igetw(&temp_zinit.start_heart,f))
19628 {
19629 return qe_invalid;
19630 }
19631
19632
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_igetw(&temp_zinit.cont_heart,f))
19633 {
19634 return qe_invalid;
19635 }
19636 }
19637
19638
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_getc(&temp_zinit.hcp,f))
19639 {
19640 return qe_invalid;
19641 }
19642
19643
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
126 if(s_version >= 14)
19644 {
19645
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19646 {
19647 return qe_invalid;
19648 }
19649
19650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(s_version<16) // July 2007
19651 {
19652 if(get_qr(qr_BRANGPICKUP+1))
19653 temp_zinit.hcp_per_hc = 0xFF;
19654
19655 //Dispose of legacy rule
19656 set_qr(qr_BRANGPICKUP+1, 0);
19657 }
19658 114 }
19659
19660
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 37 times.
126 if(s_version < 29)
19661 {
19662
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19663 return qe_invalid;
19664 89 temp_zinit.max_bombs = padding;
19665 89 }
19666
19667
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_getc(&temp_zinit.keys,f))
19668 {
19669 return qe_invalid;
19670 }
19671
19672
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&temp_zinit.rupies,f))
19673 {
19674 return qe_invalid;
19675 }
19676
19677
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_getc(&temp_zinit.triforce,f))
19678 {
19679 return qe_invalid;
19680 }
19681
19682
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
126 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19683 {
19684
2/2
✓ Branch 0 taken 7296 times.
✓ Branch 1 taken 114 times.
7410 for(int32_t i=0; i<64; i++)
19685 {
19686
2/4
✓ Branch 0 taken 7296 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7296 times.
7296 if(!p_getc(&temp_zinit.map[i],f))
19687 {
19688 return qe_invalid;
19689 }
19690 7296 }
19691
19692
2/2
✓ Branch 0 taken 7296 times.
✓ Branch 1 taken 114 times.
7410 for(int32_t i=0; i<64; i++)
19693 {
19694
2/4
✓ Branch 0 taken 7296 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7296 times.
7296 if(!p_getc(&temp_zinit.compass[i],f))
19695 {
19696 return qe_invalid;
19697 }
19698 7296 }
19699 114 }
19700 else
19701 {
19702
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19703 {
19704
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
384 if(!p_getc(&temp_zinit.map[i],f))
19705 {
19706 return qe_invalid;
19707 }
19708 384 }
19709
19710
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19711 {
19712
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
384 if(!p_getc(&temp_zinit.compass[i],f))
19713 {
19714 return qe_invalid;
19715 }
19716 384 }
19717 }
19718
19719
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if((Header->zelda_version > 0x192)||
19720 //new only
19721 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19722 {
19723
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
126 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19724 {
19725
2/2
✓ Branch 0 taken 7296 times.
✓ Branch 1 taken 114 times.
7410 for(int32_t i=0; i<64; i++)
19726 {
19727
2/4
✓ Branch 0 taken 7296 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7296 times.
7296 if(!p_getc(&temp_zinit.boss_key[i],f))
19728 {
19729 return qe_invalid;
19730 }
19731 7296 }
19732 114 }
19733 else
19734 {
19735
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19736 {
19737
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 384 times.
✗ Branch 3 not taken.
384 if(!p_getc(&temp_zinit.boss_key[i],f))
19738 {
19739 return qe_invalid;
19740 }
19741 384 }
19742 }
19743 126 }
19744
19745
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 2016 times.
2142 for(int32_t i=0; i<16; i++)
19746 {
19747
2/4
✓ Branch 0 taken 2016 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2016 times.
2016 if(!p_getc(&temp_zinit.misc[i],f))
19748 {
19749 return qe_invalid;
19750 }
19751 2016 }
19752
19753
4/4
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 12 times.
174 if(s_version < 15) for(int32_t i=0; i<4; i++)
19754 {
19755
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 if(!p_getc(&sword_hearts[i],f))
19756 {
19757 return qe_invalid;
19758 }
19759 60 }
19760
19761
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_getc(&temp_zinit.last_map,f))
19762 {
19763 return qe_invalid;
19764 }
19765
19766
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_getc(&temp_zinit.last_screen,f))
19767 {
19768 return qe_invalid;
19769 }
19770
19771
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 114 times.
126 if(s_version < 14)
19772 {
19773 byte tempmp;
19774
19775
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempmp,f))
19776 {
19777 return qe_invalid;
19778 }
19779
19780 12 temp_zinit.max_magic=tempmp;
19781
19782
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempmp,f))
19783 {
19784 return qe_invalid;
19785 }
19786
19787 12 temp_zinit.magic=tempmp;
19788 12 }
19789 else
19790 {
19791
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_igetw(&temp_zinit.max_magic,f))
19792 {
19793 return qe_invalid;
19794 }
19795
19796
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_igetw(&temp_zinit.magic,f))
19797 {
19798 return qe_invalid;
19799 }
19800 }
19801
19802
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
126 if(s_version < 15)
19803 {
19804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version < 12)
19805 {
19806 12 temp_zinit.max_magic*=32;
19807 12 temp_zinit.magic*=32;
19808 12 }
19809
19810
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 48 times.
60 for(int32_t i=0; i<4; i++)
19811 {
19812
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 if(!p_getc(&beam_hearts[i],f))
19813 {
19814 return qe_invalid;
19815 }
19816 48 }
19817
19818
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&beam_percent,f))
19819 {
19820 return qe_invalid;
19821 }
19822 12 }
19823 else
19824 {
19825
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_getc(&temp_zinit.bomb_ratio,f))
19826 {
19827 return qe_invalid;
19828 }
19829 }
19830
19831
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
126 if(s_version < 15)
19832 {
19833 byte tempbp;
19834
19835
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 48 times.
60 for(int32_t i=0; i<4; i++)
19836 {
19837
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
48 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
19838 {
19839 return qe_invalid;
19840 }
19841
19842 48 beam_power[i]=tempbp;
19843 48 }
19844
19845
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&hookshot_links,f))
19846 {
19847 return qe_invalid;
19848 }
19849
19850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version>6)
19851 {
19852 if(!p_getc(&hookshot_length,f))
19853 {
19854 return qe_invalid;
19855 }
19856
19857 if(!p_getc(&longshot_links,f))
19858 {
19859 return qe_invalid;
19860 }
19861
19862 if(!p_getc(&longshot_length,f))
19863 {
19864 return qe_invalid;
19865 }
19866 }
19867 12 }
19868
19869
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_getc(&temp_zinit.msg_more_x,f))
19870 {
19871 return qe_invalid;
19872 }
19873
19874
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_getc(&temp_zinit.msg_more_y,f))
19875 {
19876 return qe_invalid;
19877 }
19878
19879
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_getc(&temp_zinit.subscreen,f))
19880 {
19881 return qe_invalid;
19882 }
19883
19884 //old only
19885
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if((Header->zelda_version == 0x192)&&(Header->build<174))
19886 {
19887 for(int32_t i=0; i<32; i++)
19888 {
19889 if(!p_getc(&temp_zinit.boss_key[i],f))
19890 {
19891 return qe_invalid;
19892 }
19893 }
19894 }
19895
19896
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
126 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
19897 {
19898
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 114 times.
126 if(s_version <= 10)
19899 {
19900 byte tempbyte;
19901
19902
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbyte,f))
19903 {
19904 return qe_invalid;
19905 }
19906
19907 12 temp_zinit.start_dmap = (word)tempbyte;
19908 12 }
19909 else
19910 {
19911
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_igetw(&temp_zinit.start_dmap,f))
19912 {
19913 return qe_invalid;
19914 }
19915 }
19916
19917
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
19918 {
19919 return qe_invalid;
19920 }
19921 126 }
19922
19923
4/4
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 37 times.
126 if(s_version>1 && s_version < 29)
19924 {
19925
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f))
19926 return qe_invalid;
19927 77 temp_zinit.arrows = padding;
19928
19929
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f))
19930 return qe_invalid;
19931 77 temp_zinit.max_arrows = padding;
19932 77 }
19933
19934
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 114 times.
126 if(s_version>2)
19935 {
19936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(s_version <= 10)
19937 {
19938 for(int32_t i=0; i<OLDMAXLEVELS; i++)
19939 {
19940 if(!p_getc(&(temp_zinit.level_keys[i]),f))
19941 {
19942 return qe_invalid;
19943 }
19944 }
19945 }
19946 else
19947 {
19948
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<MAXLEVELS; i++)
19949 {
19950
2/4
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58368 times.
✗ Branch 3 not taken.
58368 if(!p_getc(&(temp_zinit.level_keys[i]),f))
19951 {
19952 return qe_invalid;
19953 }
19954 58368 }
19955 }
19956 114 }
19957
19958
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
126 if(s_version>3)
19959 {
19960
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_igetw(&temp_zinit.ss_grid_x,f))
19961 {
19962 return qe_invalid;
19963 }
19964
19965
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_igetw(&temp_zinit.ss_grid_y,f))
19966 {
19967 return qe_invalid;
19968 }
19969
19970
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
19971 {
19972 return qe_invalid;
19973 }
19974
19975
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
19976 {
19977 return qe_invalid;
19978 }
19979
19980
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_igetw(&temp_zinit.ss_grid_color,f))
19981 {
19982 return qe_invalid;
19983 }
19984
19985
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
19986 {
19987 return qe_invalid;
19988 }
19989
19990
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
19991 {
19992 return qe_invalid;
19993 }
19994
19995
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_igetw(&temp_zinit.ss_flags,f))
19996 {
19997 return qe_invalid;
19998 }
19999
20000
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20001
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20002 114 }
20003
20004
3/4
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
126 if(s_version>4 && s_version<15)
20005 {
20006 if(!p_getc(&moving_fairy_hearts,f))
20007 {
20008 return qe_invalid;
20009 }
20010
20011 if(!p_getc(&moving_fairy_heart_percent,f))
20012 {
20013 return qe_invalid;
20014 }
20015 }
20016
20017
3/4
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
126 if(s_version>5 && s_version < 10)
20018 {
20019 if(!p_getc(&temp,f))
20020 {
20021 return qe_invalid;
20022 }
20023
20024 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20025 }
20026
20027
3/4
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
126 if(s_version>6 && s_version<15)
20028 {
20029 if(!p_getc(&stationary_fairy_hearts,f))
20030 {
20031 return qe_invalid;
20032 }
20033
20034 if(!p_getc(&stationary_fairy_heart_percent,f))
20035 {
20036 return qe_invalid;
20037 }
20038
20039 if(!p_getc(&moving_fairy_magic,f))
20040 {
20041 return qe_invalid;
20042 }
20043
20044 if(!p_getc(&moving_fairy_magic_percent,f))
20045 {
20046 return qe_invalid;
20047 }
20048
20049 if(!p_getc(&stationary_fairy_magic,f))
20050 {
20051 return qe_invalid;
20052 }
20053
20054 if(!p_getc(&stationary_fairy_magic_percent,f))
20055 {
20056 return qe_invalid;
20057 }
20058
20059 if(!p_getc(&blue_potion_hearts,f))
20060 {
20061 return qe_invalid;
20062 }
20063
20064 if(!p_getc(&blue_potion_heart_percent,f))
20065 {
20066 return qe_invalid;
20067 }
20068
20069 if(!p_getc(&red_potion_hearts,f))
20070 {
20071 return qe_invalid;
20072 }
20073
20074 if(!p_getc(&red_potion_heart_percent,f))
20075 {
20076 return qe_invalid;
20077 }
20078
20079 if(!p_getc(&blue_potion_magic,f))
20080 {
20081 return qe_invalid;
20082 }
20083
20084 if(!p_getc(&blue_potion_magic_percent,f))
20085 {
20086 return qe_invalid;
20087 }
20088
20089 if(!p_getc(&red_potion_magic,f))
20090 {
20091 return qe_invalid;
20092 }
20093
20094 if(!p_getc(&red_potion_magic_percent,f))
20095 {
20096 return qe_invalid;
20097 }
20098 }
20099
20100
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
126 if(s_version>6)
20101 {
20102
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_getc(&temp_zinit.subscreen_style,f))
20103 {
20104 return qe_invalid;
20105 }
20106 114 }
20107
20108
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
126 if(s_version>7)
20109 {
20110
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_getc(&temp_zinit.usecustomsfx,f))
20111 {
20112 return qe_invalid;
20113 }
20114 114 }
20115
20116
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
126 if(s_version>8)
20117 {
20118
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_igetw(&temp_zinit.max_rupees,f))
20119 {
20120 return qe_invalid;
20121 }
20122
20123
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_igetw(&temp_zinit.max_keys,f))
20124 {
20125 return qe_invalid;
20126 }
20127 114 }
20128
20129
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
126 if(s_version>16)
20130 {
20131
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_getc(&temp_zinit.gravity,f))
20132 {
20133 return qe_invalid;
20134 }
20135
20136
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_igetw(&temp_zinit.terminalv,f))
20137 {
20138 return qe_invalid;
20139 }
20140
20141
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_getc(&temp_zinit.msg_speed,f))
20142 {
20143 return qe_invalid;
20144 }
20145
20146
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_getc(&temp_zinit.transition_type,f))
20147 {
20148 return qe_invalid;
20149 }
20150
20151
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20152 {
20153 return qe_invalid;
20154 }
20155 114 }
20156
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 else if (replay_version_check(0, 13))
20157 12 temp_zinit.msg_speed = 0;
20158
20159
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
126 if(s_version>17)
20160 {
20161
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20162 {
20163 return qe_invalid;
20164 }
20165 114 }
20166
20167 //expaned init data for larger values in 2.55
20168
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20169 {
20170
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_igetw(&temp_zinit.bombs,f))
20171 {
20172 return qe_invalid;
20173 }
20174
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_igetw(&temp_zinit.super_bombs,f))
20175 {
20176 return qe_invalid;
20177 }
20178
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_igetw(&temp_zinit.max_bombs,f))
20179 {
20180 return qe_invalid;
20181 }
20182
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_igetw(&temp_zinit.max_sbombs,f))
20183 {
20184 return qe_invalid;
20185 }
20186
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_igetw(&temp_zinit.arrows,f))
20187 {
20188 return qe_invalid;
20189 }
20190
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_igetw(&temp_zinit.max_arrows,f))
20191 {
20192 return qe_invalid;
20193 }
20194
20195 37 }
20196
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if ( s_version >= 20 )
20197 {
20198
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_igetw(&temp_zinit.heroStep,f))
20199 {
20200 return qe_invalid;
20201 }
20202 37 }
20203 else
20204 {
20205 89 temp_zinit.heroStep = 150; //1.5 pixels per frame
20206 }
20207
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if ( s_version >= 21 )
20208 {
20209
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20210 {
20211 return qe_invalid;
20212 }
20213 37 }
20214 else
20215 {
20216 89 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20217 }
20218 //old only
20219
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if((Header->zelda_version == 0x192)&&(Header->build<174))
20220 {
20221 byte items2;
20222
20223 if(!p_getc(&items2,f))
20224 {
20225 return qe_invalid;
20226 }
20227
20228 temp_zinit.items[iDivineFire]=(get_bit(&items2, idI_DFIRE)!=0);
20229 temp_zinit.items[iDivineEscape]=(get_bit(&items2, idI_FWIND)!=0);
20230 temp_zinit.items[iDivineProtection]=(get_bit(&items2, idI_NLOVE)!=0);
20231 }
20232
20233
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(Header->zelda_version < 0x193)
20234 {
20235 for(int32_t q=0; q<96; q++)
20236 {
20237 if(!p_getc(&padding,f))
20238 {
20239 return qe_invalid;
20240 }
20241 }
20242
20243 //new only
20244 if((Header->zelda_version == 0x192)&&(Header->build>173))
20245 {
20246 if(!p_getc(&padding,f))
20247 {
20248 return qe_invalid;
20249 }
20250
20251 if(!p_getc(&padding,f))
20252 {
20253 return qe_invalid;
20254 }
20255 }
20256 }
20257 126 }
20258
20259
3/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20260 {
20261 //temp_zinit.shield=i_smallshield;
20262
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 30 times.
46 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20263
20264
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(sshieldid != -1)
20265 16 temp_zinit.items[sshieldid] = true;
20266 16 }
20267
20268
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20269 {
20270 4 temp_zinit.hc=3;
20271 4 temp_zinit.start_heart=3;
20272 4 temp_zinit.cont_heart=3;
20273 4 temp_zinit.max_bombs=8;
20274 4 }
20275
20276
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20277 {
20278 4 sword_hearts[0]=0;
20279 4 sword_hearts[1]=5;
20280 4 sword_hearts[2]=12;
20281 4 sword_hearts[3]=21;
20282 4 }
20283
20284
3/4
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
130 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20285 {
20286 4 temp_zinit.last_map=0;
20287 4 temp_zinit.last_screen=0;
20288 4 }
20289
20290
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20291 {
20292 4 temp_zinit.max_magic=0;
20293 4 temp_zinit.magic=0;
20294
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20295 4 }
20296
20297
3/4
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
130 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20298 {
20299
20300
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20301 {
20302 16 beam_hearts[x]=100;
20303 16 }
20304
20305
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<idBP_MAX; i++)
20306 {
20307
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20308
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 set_qr(qr_LENSHINTS+i,0);
20309 16 }
20310
20311
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 for(int32_t x=0; x<4; x++)
20312 {
20313
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20314 16 }
20315
20316
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_HIDECARRIEDITEMS,0);
20317 4 hookshot_links=100;
20318 4 temp_zinit.msg_more_x=224;
20319 4 temp_zinit.msg_more_y=64;
20320 4 }
20321
20322 // Okay, let's put these legacy values into itemsbuf.
20323
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version < 15)
20324
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4096 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
20325 {
20326
11/11
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 3936 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
4096 switch(i)
20327 {
20328 case iFairyStill:
20329 16 itemsbuf[i].misc1 = stationary_fairy_hearts;
20330 16 itemsbuf[i].misc2 = stationary_fairy_magic;
20331 16 itemsbuf[i].misc3 = 0;
20332 16 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20333 16 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20334 16 break;
20335
20336 case iFairyMoving:
20337 16 itemsbuf[i].misc1 = moving_fairy_hearts;
20338 16 itemsbuf[i].misc2 = moving_fairy_magic;
20339 16 itemsbuf[i].misc3 = 50;
20340 16 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20341 16 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20342 16 break;
20343
20344 case iRPotion:
20345 16 itemsbuf[i].misc1 = red_potion_hearts;
20346 16 itemsbuf[i].misc2 = red_potion_magic;
20347 16 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20348 16 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20349 16 break;
20350
20351 case iBPotion:
20352 16 itemsbuf[i].misc1 = blue_potion_hearts;
20353 16 itemsbuf[i].misc2 = blue_potion_magic;
20354 16 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20355 16 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20356 16 break;
20357
20358 case iSword:
20359 16 itemsbuf[i].pickup_hearts = sword_hearts[0];
20360 16 itemsbuf[i].misc1 = beam_hearts[0];
20361 16 itemsbuf[i].misc2 = beam_power[0];
20362 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20363
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20364 16 break;
20365
20366 case iWSword:
20367 16 itemsbuf[i].pickup_hearts = sword_hearts[1];
20368 16 itemsbuf[i].misc1 = beam_hearts[1];
20369 16 itemsbuf[i].misc2 = beam_power[1];
20370
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20371 16 break;
20372
20373 case iMSword:
20374 16 itemsbuf[i].pickup_hearts = sword_hearts[2];
20375 16 itemsbuf[i].misc1 = beam_hearts[2];
20376 16 itemsbuf[i].misc2 = beam_power[2];
20377
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20378 16 break;
20379
20380 case iXSword:
20381 16 itemsbuf[i].pickup_hearts = sword_hearts[3];
20382 16 itemsbuf[i].misc1 = beam_hearts[3];
20383 16 itemsbuf[i].misc2 = beam_power[3];
20384
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20385 16 break;
20386
20387 case iHookshot:
20388 16 itemsbuf[i].misc1 = hookshot_length;
20389 16 itemsbuf[i].misc2 = hookshot_links;
20390 16 break;
20391
20392 case iLongshot:
20393 16 itemsbuf[i].misc1 = longshot_length;
20394 16 itemsbuf[i].misc2 = longshot_links;
20395 16 break;
20396 }
20397 4112 }
20398
20399
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20400 {
20401 //was new subscreen rule
20402
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.subscreen=get_qr(qr_FREEFORM)?1:0;
20403
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_FREEFORM,0);
20404 4 }
20405
20406
3/4
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
130 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20407 {
20408 4 temp_zinit.start_dmap=0;
20409 4 }
20410
20411
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20412 {
20413
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20414 4 }
20415
20416
4/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
130 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20417 {
20418 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20419 temp_zinit.max_rupees=999;
20420 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20421 }
20422
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20423 {
20424 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20425 temp_zinit.max_bombs = 8;
20426 }
20427 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20428 //time to ensure that we port all new values properly:
20429
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(Header->zelda_version < 0x250)
20430 {
20431
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20432 16 }
20433
20434
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(s_version > 21)
20435 {
20436
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_getc(&temp_zinit.hp_per_heart,f))
20437 {
20438 return qe_invalid;
20439 }
20440
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_getc(&temp_zinit.magic_per_block,f))
20441 {
20442 return qe_invalid;
20443 }
20444
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20445 {
20446 return qe_invalid;
20447 }
20448
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20449 {
20450 return qe_invalid;
20451 }
20452 37 }
20453 else
20454 {
20455 93 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20456 93 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20457 93 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20458 93 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20459 }
20460
20461
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(s_version > 22)
20462 {
20463
2/2
✓ Branch 0 taken 925 times.
✓ Branch 1 taken 37 times.
962 for(int32_t q = 0; q < 25; ++q)
20464 {
20465
2/4
✓ Branch 0 taken 925 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 925 times.
925 if(!p_igetw(&temp_zinit.scrcnt[q],f))
20466 {
20467 return qe_invalid;
20468 }
20469 925 }
20470
2/2
✓ Branch 0 taken 925 times.
✓ Branch 1 taken 37 times.
962 for(int32_t q = 0; q < 25; ++q)
20471 {
20472
2/4
✓ Branch 0 taken 925 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 925 times.
925 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f))
20473 {
20474 return qe_invalid;
20475 }
20476 925 }
20477 37 }
20478 else
20479 {
20480
2/2
✓ Branch 0 taken 2325 times.
✓ Branch 1 taken 93 times.
2418 for(int32_t q = 0; q < 25; ++q)
20481 {
20482 2325 temp_zinit.scrcnt[q] = 0;
20483 2325 temp_zinit.scrmaxcnt[q] = 0;
20484 2325 }
20485 }
20486
20487
20488
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(s_version > 23)
20489 {
20490
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_getc(&temp_zinit.dither_type,f))
20491 {
20492 return qe_invalid;
20493 }
20494
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_getc(&temp_zinit.dither_arg,f))
20495 {
20496 return qe_invalid;
20497 }
20498
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_getc(&temp_zinit.dither_percent,f))
20499 {
20500 return qe_invalid;
20501 }
20502
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_getc(&temp_zinit.def_lightrad,f))
20503 {
20504 return qe_invalid;
20505 }
20506
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_getc(&temp_zinit.transdark_percent,f))
20507 {
20508 return qe_invalid;
20509 }
20510 37 }
20511 else
20512 {
20513 93 temp_zinit.dither_type = 0;
20514 93 temp_zinit.dither_arg = 0;
20515 93 temp_zinit.dither_percent = 20;
20516 93 temp_zinit.def_lightrad = 24;
20517 93 temp_zinit.transdark_percent = 0;
20518 }
20519
20520
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(s_version > 24)
20521 {
20522
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_getc(&temp_zinit.darkcol,f))
20523 {
20524 return qe_invalid;
20525 }
20526 37 }
20527 else
20528 {
20529 93 temp_zinit.darkcol = BLACK;
20530 }
20531
20532
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(s_version > 25)
20533 {
20534
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_igetl(&temp_zinit.gravity2,f))
20535 {
20536 return qe_invalid;
20537 }
20538
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_igetl(&temp_zinit.swimgravity,f))
20539 {
20540 return qe_invalid;
20541 }
20542 37 }
20543 else
20544 {
20545 93 temp_zinit.gravity2 = temp_zinit.gravity*100;
20546 93 temp_zinit.swimgravity = 5;
20547 }
20548
20549
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(s_version > 26)
20550 {
20551
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20552 {
20553 return qe_invalid;
20554 }
20555
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20556 {
20557 return qe_invalid;
20558 }
20559
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20560 {
20561 return qe_invalid;
20562 }
20563 37 }
20564 else
20565 {
20566 93 temp_zinit.heroSideswimUpStep = 150;
20567 93 temp_zinit.heroSideswimSideStep = 100;
20568 93 temp_zinit.heroSideswimDownStep = 75;
20569 }
20570
20571
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(s_version > 27)
20572 {
20573
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20574 {
20575 return qe_invalid;
20576 }
20577 37 }
20578 else
20579 {
20580 93 temp_zinit.exitWaterJump = 0;
20581 }
20582
20583
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(s_version > 29)
20584 {
20585
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20586 {
20587 return qe_invalid;
20588 }
20589 37 }
20590 else
20591 {
20592 93 temp_zinit.bunny_ltm = 0;
20593 }
20594
20595
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(s_version > 30)
20596 {
20597
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_getc(&temp_zinit.switchhookstyle,f))
20598 {
20599 return qe_invalid;
20600 }
20601 37 }
20602 else
20603 {
20604 93 temp_zinit.switchhookstyle = 1;
20605 }
20606
20607
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(s_version > 31)
20608 {
20609
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(!p_getc(&temp_zinit.magicdrainrate,f))
20610 {
20611 return qe_invalid;
20612 }
20613 37 }
20614 else
20615 {
20616
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
20617
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20618 }
20619
20620
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 temp_zinit.clear_genscript();
20621
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(s_version > 32)
20622 {
20623 35 word numgenscript = 0;
20624
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetw(&numgenscript,f))
20625 return qe_invalid;
20626
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
35 if (!(numgenscript >= 0 && numgenscript <= NUMSCRIPTSGENERIC))
20627 return qe_invalid;
20628
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 for(auto q = 1; q < numgenscript; ++q)
20629 {
20630 if(!p_getc(&padding,f))
20631 return qe_invalid;
20632 if(!(padding&2))
20633 continue;
20634 temp_zinit.gen_doscript[q] = padding&1;
20635 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20636 return qe_invalid;
20637 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20638 return qe_invalid;
20639 for(auto p = 0; p < 8; ++p)
20640 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20641 return qe_invalid;
20642 if(!p_igetl(&temp_zinit.gen_dataSize[q],f))
20643 return qe_invalid;
20644 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f))
20645 return qe_invalid;
20646 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20647 return qe_invalid;
20648 }
20649 35 }
20650
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 98 times.
130 if(s_version > 33)
20651 {
20652
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20653 return qe_invalid;
20654
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 if(!p_getc(&temp_zinit.hero_swim_div,f))
20655 return qe_invalid;
20656 32 }
20657
20658
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 zinit = temp_zinit;
20659
20660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(zinit.heroAnimationStyle==las_zelda3slow)
20661 {
20662 hero_animation_speed=2;
20663 }
20664 else
20665 {
20666 130 hero_animation_speed=1;
20667 }
20668
20669 130 return 0;
20670 442 }
20671
20672 /*
20673 void setupitemdropsets()
20674 {
20675 for(int32_t i=0; i<isMAX; i++)
20676 {
20677 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
20678 }
20679 }
20680 */
20681
20682 118 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build)
20683 {
20684 118 build=build; // here to prevent compiler warnings
20685 dword dummy_dword;
20686 118 word item_drop_sets_to_read=0;
20687 item_drop_object tempitemdrop;
20688 118 word s_version=0, s_cversion=0;
20689
20690
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 118 times.
30326 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
20691 {
20692 30208 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
20693 30208 }
20694
20695
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 4 times.
118 if(version > 0x192)
20696 {
20697 114 item_drop_sets_to_read=0;
20698
20699 //section version info
20700
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&s_version,f))
20701 {
20702 return qe_invalid;
20703 }
20704
20705 114 FFCore.quest_format[vItemDropsets] = s_version;
20706
20707 //al_trace("Item drop sets version %d\n", s_version);
20708
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&s_cversion,f))
20709 {
20710 return qe_invalid;
20711 }
20712
20713 //section size
20714
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&dummy_dword,f))
20715 {
20716 return qe_invalid;
20717 }
20718
20719 //finally... section data
20720
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&item_drop_sets_to_read,f))
20721 {
20722 return qe_invalid;
20723 }
20724
20725
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if (!(item_drop_sets_to_read >= 0 && item_drop_sets_to_read <= MAXITEMDROPSETS))
20726 {
20727 return qe_invalid;
20728 }
20729 114 }
20730 else
20731 {
20732 4 init_item_drop_sets();
20733 }
20734
20735
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 114 times.
118 if(s_version>=1)
20736 {
20737
2/2
✓ Branch 0 taken 2082 times.
✓ Branch 1 taken 114 times.
2196 for(int32_t i=0; i<item_drop_sets_to_read; i++)
20738 {
20739
1/2
✓ Branch 0 taken 2082 times.
✗ Branch 1 not taken.
2082 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f))
20740 {
20741 return qe_invalid;
20742 }
20743
20744
2/2
✓ Branch 0 taken 20820 times.
✓ Branch 1 taken 2082 times.
22902 for(int32_t j=0; j<10; ++j)
20745 {
20746
1/2
✓ Branch 0 taken 20820 times.
✗ Branch 1 not taken.
20820 if(!p_igetw(&tempitemdrop.item[j],f))
20747 {
20748 return qe_invalid;
20749 }
20750 20820 }
20751
20752
2/2
✓ Branch 0 taken 22902 times.
✓ Branch 1 taken 2082 times.
24984 for(int32_t j=0; j<11; ++j)
20753 {
20754
1/2
✓ Branch 0 taken 22902 times.
✗ Branch 1 not taken.
22902 if(!p_igetw(&tempitemdrop.chance[j],f))
20755 {
20756 return qe_invalid;
20757 }
20758 22902 }
20759
20760 // Dec 2008: Addition of the 'Tall Grass' set, #12,
20761 // overrides the quest's set #12.
20762
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2082 if(s_version<2 && i==12)
20763 continue;
20764
20765 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
20766
1/4
✓ Branch 0 taken 2082 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2082 if(s_version<2) for(int32_t j=0; j<10; ++j)
20767 {
20768 int32_t it = tempitemdrop.item[j];
20769
20770 if((itemsbuf[it].family == itype_rupee
20771 && ((itemsbuf[it].amount)&0xFFF) == 10)
20772 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
20773 {
20774 tempitemdrop.chance[j+1]=0;
20775 }
20776 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
20777 {
20778 tempitemdrop.chance[j+1]=0;
20779 }
20780
20781 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
20782 if(itemsbuf[it].family == itype_misc)
20783 {
20784 // If a non-gameplay item was selected, then item drop was aborted.
20785 // Reflect this by increasing the 'Nothing' chance accordingly.
20786 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
20787 tempitemdrop.chance[j+1]=0;
20788 }
20789 }
20790
20791 2082 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
20792 2082 }
20793 114 }
20794
20795 118 return 0;
20796 118 }
20797
20798 114 int32_t readfavorites(PACKFILE *f, int32_t, word)
20799 {
20800 int32_t temp_num;
20801 dword dummy_dword;
20802 word num_favorite_combos;
20803 word num_favorite_combo_aliases;
20804 114 word s_version=0, s_cversion=0;
20805
20806 //section version info
20807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_igetw(&s_version,f))
20808 {
20809 return qe_invalid;
20810 }
20811
20812 114 FFCore.quest_format[vFavourites] = s_version;
20813
20814
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&s_cversion,f))
20815 {
20816 return qe_invalid;
20817 }
20818
20819 //section size
20820
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&dummy_dword,f))
20821 {
20822 return qe_invalid;
20823 }
20824
20825 114 word per_row = FAVORITECOMBO_PER_ROW;
20826 114 word per_page = FAVORITECOMBO_PER_PAGE;
20827
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 32 times.
114 if(s_version >= 3)
20828
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_igetw(&per_row,f))
20829 return qe_invalid;
20830
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 8 times.
114 if(s_version >= 4)
20831
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&per_page,f))
20832 return qe_invalid;
20833 //finally... section data
20834
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&num_favorite_combos,f))
20835 {
20836 return qe_invalid;
20837 }
20838
20839 //Hack; port old favorite combos
20840
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 82 times.
114 if(s_version < 3 && num_favorite_combos == 100)
20841 82 per_row = 13;
20842
20843
2/2
✓ Branch 0 taken 143640 times.
✓ Branch 1 taken 114 times.
143754 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
20844 143640 favorite_combos[q] = -1;
20845 114 byte favtype = 0;
20846
2/2
✓ Branch 0 taken 9368 times.
✓ Branch 1 taken 114 times.
9482 for(int32_t i=0; i<num_favorite_combos; i++)
20847 {
20848
2/2
✓ Branch 0 taken 1144 times.
✓ Branch 1 taken 8224 times.
9368 if (s_version >= 4)
20849 {
20850
1/2
✓ Branch 0 taken 1144 times.
✗ Branch 1 not taken.
1144 if (!p_getc(&favtype, f))
20851 {
20852 return qe_invalid;
20853 }
20854 1144 }
20855 else
20856 8224 favtype = 0;
20857
1/2
✓ Branch 0 taken 9368 times.
✗ Branch 1 not taken.
9368 if(!p_igetl(&temp_num,f))
20858 {
20859 return qe_invalid;
20860 }
20861
20862
2/2
✓ Branch 0 taken 1144 times.
✓ Branch 1 taken 8224 times.
9368 if(per_row == FAVORITECOMBO_PER_ROW)
20863 {
20864 1144 favorite_combos[i] = temp_num;
20865 1144 favorite_combo_modes[i] = favtype;
20866 1144 }
20867 else
20868 {
20869 8224 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
20870 8224 favorite_combos[new_i]=temp_num;
20871 8224 favorite_combo_modes[new_i] = favtype;
20872 }
20873 9368 }
20874
20875 // Discard the separate favorite aliases list from previous versions
20876
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 106 times.
114 if(s_version<4)
20877 {
20878
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if (!p_igetw(&num_favorite_combo_aliases, f))
20879 {
20880 return qe_invalid;
20881 }
20882
20883
2/2
✓ Branch 0 taken 8200 times.
✓ Branch 1 taken 106 times.
8306 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
20884 {
20885
1/2
✓ Branch 0 taken 8200 times.
✗ Branch 1 not taken.
8200 if (!p_igetl(&temp_num, f))
20886 {
20887 return qe_invalid;
20888 }
20889 8200 }
20890 106 }
20891
20892 114 word max_combo_cols = 0;
20893 114 word max_mappages = 0;
20894
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 32 times.
114 if(s_version >= 2)
20895 {
20896
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_igetw(&max_combo_cols,f))
20897 return qe_invalid;
20898 32 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
20899
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 32 times.
160 for(int q = 0; q < max_combo_cols; ++q)
20900 {
20901
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetl(&tmp,f))
20902 return qe_invalid;
20903
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetl(&tmp2,f))
20904 return qe_invalid;
20905
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetl(&tmp3,f))
20906 return qe_invalid;
20907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(q < MAX_COMBO_COLS)
20908 {
20909 128 First[q] = tmp;
20910 128 combo_alistpos[q] = tmp2;
20911 128 combo_pool_listpos[q] = tmp3;
20912 128 }
20913 128 }
20914
20915
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_igetw(&max_mappages,f))
20916 return qe_invalid;
20917
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 32 times.
320 for(int q = 0; q < max_mappages; ++q)
20918 {
20919
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(!p_igetl(&tmp,f))
20920 return qe_invalid;
20921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(!p_igetl(&tmp2,f))
20922 return qe_invalid;
20923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(q < MAX_MAPPAGE_BTNS)
20924 {
20925 288 map_page[q].map = tmp;
20926 288 map_page[q].screen = tmp2;
20927 288 }
20928 288 }
20929 32 }
20930
20931
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 114 times.
442 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
20932 {
20933 328 First[q] = 0;
20934 328 combo_alistpos[q] = 0;
20935 328 combo_pool_listpos[q] = 0;
20936 328 }
20937
2/2
✓ Branch 0 taken 738 times.
✓ Branch 1 taken 114 times.
852 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
20938 {
20939 738 map_page[q].map = 0;
20940 738 map_page[q].screen = 0;
20941 738 }
20942
20943 114 return 0;
20944 114 }
20945
20946 /*
20947 switch (ret) {
20948 case 0:
20949 break;
20950
20951 case qe_invalid:
20952 goto invalid;
20953 break;
20954 default:
20955 pack_fclose(f);
20956 if(!oldquest)
20957 delete_file(tmpfilename);
20958 return ret;
20959 break;
20960 }
20961 */
20962
20963 const char *skip_text[skip_max]=
20964 {
20965 "skip_header", "skip_rules", "skip_strings", "skip_misc",
20966 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
20967 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
20968 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
20969 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
20970 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
20971 "skip_favorites"
20972 };
20973
20974
20975 void port250QuestRules(){
20976
20977 portCandleRules(); //Candle
20978 portBombRules();
20979
20980 }
20981
20982 void portCandleRules()
20983 {
20984 bool hurtshero = get_qr(qr_FIREPROOFHERO);
20985 //itemdata itemsbuf;
20986 for ( int32_t q = 0; q < MAXITEMS; q++ )
20987 {
20988 if ( itemsbuf[q].family == itype_candle )
20989 {
20990 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
20991 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
20992 }
20993 }
20994 }
20995
20996 void portBombRules()
20997 {
20998 bool hurtshero = get_qr(qr_OUCHBOMBS);
20999 //itemdata itemsbuf;
21000 for ( int32_t q = 0; q < MAXITEMS; q++ )
21001 {
21002 if ( itemsbuf[q].family == itype_bomb )
21003 {
21004 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21005 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21006 }
21007 }
21008 }
21009
21010 2916 static int section_id_to_enum(int id)
21011 {
21012
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 126 times.
✓ Branch 4 taken 126 times.
✓ Branch 5 taken 126 times.
✓ Branch 6 taken 114 times.
✓ Branch 7 taken 126 times.
✓ Branch 8 taken 126 times.
✓ Branch 9 taken 126 times.
✓ Branch 10 taken 126 times.
✓ Branch 11 taken 126 times.
✓ Branch 12 taken 126 times.
✓ Branch 13 taken 114 times.
✓ Branch 14 taken 114 times.
✓ Branch 15 taken 126 times.
✓ Branch 16 taken 126 times.
✓ Branch 17 taken 114 times.
✓ Branch 18 taken 114 times.
✓ Branch 19 taken 114 times.
✓ Branch 20 taken 114 times.
✓ Branch 21 taken 126 times.
✓ Branch 22 taken 126 times.
✓ Branch 23 taken 114 times.
✓ Branch 24 taken 114 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2916 switch (id)
21013 {
21014 case ID_HEADER: return skip_header;
21015 126 case ID_RULES: return skip_rules;
21016 126 case ID_STRINGS: return skip_strings;
21017 126 case ID_MISC: return skip_misc;
21018 126 case ID_TILES: return skip_tiles;
21019 126 case ID_COMBOS: return skip_combos;
21020 114 case ID_COMBOALIASES: return skip_comboaliases;
21021 126 case ID_CSETS: return skip_csets;
21022 126 case ID_MAPS: return skip_maps;
21023 126 case ID_DMAPS: return skip_dmaps;
21024 126 case ID_DOORS: return skip_doors;
21025 126 case ID_ITEMS: return skip_items;
21026 126 case ID_WEAPONS: return skip_weapons;
21027 114 case ID_COLORS: return skip_colors;
21028 114 case ID_ICONS: return skip_icons;
21029 126 case ID_INITDATA: return skip_initdata;
21030 126 case ID_GUYS: return skip_guys;
21031 114 case ID_HEROSPRITES: return skip_herosprites;
21032 114 case ID_SUBSCREEN: return skip_subscreens;
21033 114 case ID_FFSCRIPT: return skip_ffscript;
21034 114 case ID_SFX: return skip_sfx;
21035 126 case ID_MIDIS: return skip_midis;
21036 126 case ID_CHEATS: return skip_cheats;
21037 114 case ID_ITEMDROPSETS: return skip_itemdropsets;
21038 114 case ID_FAVORITES: return skip_favorites;
21039 case ID_ZINFO: return skip_zinfo;
21040 }
21041
21042 return -1;
21043 2916 }
21044
21045 2916 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21046 {
21047 2916 int section_enum = section_id_to_enum(section_id);
21048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2916 times.
2916 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2916 times.
2916 if (skip)
21050 {
21051 word s_version;
21052 if (!p_igetw(&s_version,f))
21053 {
21054 return qe_invalid;
21055 }
21056
21057 word c_version;
21058 if (!p_igetw(&c_version,f))
21059 {
21060 return qe_invalid;
21061 }
21062
21063 if (section_id == ID_RULES && s_version > 16)
21064 {
21065 dword dummy;
21066 if (!p_igetl(&dummy,f))
21067 {
21068 return qe_invalid;
21069 }
21070 }
21071
21072 if (section_id == ID_FFSCRIPT && s_version >= 18)
21073 {
21074 word dummy;
21075 if (!p_igetw(&dummy,f))
21076 {
21077 return qe_invalid;
21078 }
21079 }
21080
21081 dword section_length;
21082 if (!p_igetl(&section_length,f))
21083 {
21084 return qe_invalid;
21085 }
21086
21087 if (pack_fseek(f, section_length))
21088 {
21089 return qe_invalid;
21090 }
21091
21092 if (!pack_feof(f))
21093 {
21094 if (!p_mgetl(&section_id,f))
21095 {
21096 return qe_invalid;
21097 }
21098 }
21099
21100 return qe_cancel;
21101 }
21102
21103 2916 return qe_OK;
21104 2916 }
21105
21106 //Internal function for loadquest wrapper
21107 130 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, const byte *skip_flags, byte printmetadata)
21108 {
21109 130 DMapEditorLastMaptileUsed = 0;
21110 130 combosread=false;
21111 130 mapsread=false;
21112 130 fixffcs=false;
21113
21114 // show_progress=true;
21115 char tmpfilename[L_tmpnam];
21116 130 temp_name(tmpfilename);
21117 // char percent_done[30];
21118 130 bool catchup=false;
21119 byte tempbyte;
21120 130 word old_map_count=map_count;
21121
21122 130 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21123 130 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21124 130 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21125
21126
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(get_bit(skip_flags, skip_rules))
21127 {
21128 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21129 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21130 }
21131
21132 130 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21133 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21134
21135
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(get_bit(skip_flags, skip_midis))
21136 {
21137 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21138 }
21139
21140
21141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(!get_bit(skip_flags, skip_ffscript))
21142 {
21143 130 zScript.clear();
21144 130 globalmap.clear();
21145 130 genericmap.clear();
21146 130 ffcmap.clear();
21147 130 itemmap.clear();
21148 130 npcmap.clear();
21149 130 ewpnmap.clear();
21150 130 lwpnmap.clear();
21151 130 playermap.clear();
21152 130 dmapmap.clear();
21153 130 screenmap.clear();
21154 130 itemspritemap.clear();
21155 130 comboscriptmap.clear();
21156 130 subscreenmap.clear();
21157
21158
2/2
✓ Branch 0 taken 66430 times.
✓ Branch 1 taken 130 times.
66560 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21159 {
21160 66430 ffcmap[i].clear();
21161 66430 }
21162
21163 130 globalmap[0].slotname = "Slot 1:";
21164 130 globalmap[0].scriptname = "~Init";
21165 130 globalmap[0].update();
21166
21167
2/2
✓ Branch 0 taken 910 times.
✓ Branch 1 taken 130 times.
1040 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21168 {
21169 910 globalmap[i].clear();
21170 910 }
21171
21172
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21173 {
21174 33150 itemmap[i].clear();
21175 33150 }
21176
21177 //new script types -- prevent carrying over to a quest that you load after reading them
21178 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21179
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21180 {
21181 33150 npcmap[i].clear();
21182 33150 }
21183
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21184 {
21185 33150 lwpnmap[i].clear();
21186 33150 }
21187
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21188 {
21189 33150 ewpnmap[i].clear();
21190 33150 }
21191
2/2
✓ Branch 0 taken 520 times.
✓ Branch 1 taken 130 times.
650 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21192 {
21193 520 playermap[i].clear();
21194 520 }
21195
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21196 {
21197 33150 dmapmap[i].clear();
21198 33150 }
21199
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21200 {
21201 33150 screenmap[i].clear();
21202 33150 }
21203
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21204 {
21205 33150 itemspritemap[i].clear();
21206 33150 }
21207
2/2
✓ Branch 0 taken 66430 times.
✓ Branch 1 taken 130 times.
66560 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21208 {
21209 66430 comboscriptmap[i].clear();
21210 66430 }
21211
2/2
✓ Branch 0 taken 66430 times.
✓ Branch 1 taken 130 times.
66560 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21212 {
21213 66430 genericmap[i].clear();
21214 66430 }
21215
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
21216 {
21217 33150 subscreenmap[i].clear();
21218 33150 }
21219
21220 130 reset_scripts();
21221 130 }
21222
21223 zquestheader tempheader;
21224 130 memset(&tempheader, 0, sizeof(zquestheader));
21225 130 zinfo tempzi;
21226 130 tempzi.clear();
21227 130 load_tmp_zi = &tempzi;
21228
21229 // oldquest flag is set when an unencrypted qst file is suspected.
21230 130 bool oldquest = false;
21231 130 int32_t open_error=0;
21232 130 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21233
21234
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if (!f)
21235 {
21236 ASSERT(open_error != 0);
21237 return open_error;
21238 }
21239 char zinfofilename[2048];
21240 130 replace_extension(zinfofilename, filename, "zinfo", 2047);
21241 130 int32_t ret=0;
21242
21243 //header
21244 130 box_out("Reading Header...");
21245 130 ret=readheader(f, &tempheader, printmetadata);
21246
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
130 checkstatus(ret);
21247 130 box_out("okay.");
21248 130 box_eol();
21249
21250
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 37 times.
130 if(read_zinfo)
21251 {
21252 37 box_out("Reading ZInfo - ");
21253
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 36 times.
37 box_out(read_ext_zinfo ? "External..." : "Internal...");
21254
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 36 times.
37 if(read_ext_zinfo)
21255 {
21256 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21257 1 ret=readzinfo(inf, tempzi, tempheader);
21258
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21259
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21260 1 }
21261 else
21262 {
21263 36 ret=readzinfo(f, tempzi, tempheader);
21264
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
36 checkstatus(ret);
21265 }
21266 37 box_out("okay.");
21267 37 box_eol();
21268 37 }
21269
21270
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(tempheader.zelda_version>=0x193)
21271 {
21272 dword section_id;
21273
21274 //section id
21275
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_mgetl(&section_id,f))
21276 {
21277 return qe_invalid;
21278 }
21279
21280 126 std::set<dword> seen_sections;
21281
21282
3/4
✓ Branch 0 taken 3042 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2916 times.
✓ Branch 3 taken 126 times.
3042 while(!pack_feof(f))
21283 {
21284
2/4
✓ Branch 0 taken 2916 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2916 times.
✗ Branch 3 not taken.
2916 if (seen_sections.contains(section_id))
21285 return qe_invalid;
21286
1/2
✓ Branch 0 taken 2916 times.
✗ Branch 1 not taken.
2916 seen_sections.insert(section_id);
21287
21288
2/4
✓ Branch 0 taken 2916 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2916 times.
✗ Branch 3 not taken.
2916 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21289 {
21290 if (retval == qe_cancel)
21291 continue;
21292 checkstatus(retval);
21293 }
21294
21295
24/25
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 126 times.
✓ Branch 4 taken 126 times.
✓ Branch 5 taken 114 times.
✓ Branch 6 taken 126 times.
✓ Branch 7 taken 126 times.
✓ Branch 8 taken 126 times.
✓ Branch 9 taken 126 times.
✓ Branch 10 taken 126 times.
✓ Branch 11 taken 126 times.
✓ Branch 12 taken 114 times.
✓ Branch 13 taken 114 times.
✓ Branch 14 taken 126 times.
✓ Branch 15 taken 126 times.
✓ Branch 16 taken 114 times.
✓ Branch 17 taken 114 times.
✓ Branch 18 taken 114 times.
✓ Branch 19 taken 114 times.
✓ Branch 20 taken 126 times.
✓ Branch 21 taken 126 times.
✓ Branch 22 taken 114 times.
✓ Branch 23 taken 114 times.
✗ Branch 24 not taken.
2916 switch(section_id)
21296 {
21297 case ID_RULES:
21298
21299 //rules
21300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21301 {
21302 box_out("found.");
21303 box_eol();
21304 catchup=false;
21305 }
21306
21307
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Rules...");
21308
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readrules(f, &tempheader);
21309
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21310
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21311
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21312 126 break;
21313
21314 case ID_STRINGS:
21315
21316 //strings
21317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21318 {
21319 box_out("found.");
21320 box_eol();
21321 catchup=false;
21322 }
21323
21324
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Strings...");
21325
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readstrings(f, &tempheader);
21326
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21327
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21328
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21329 126 break;
21330
21331 case ID_MISC:
21332
21333 //misc data
21334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21335 {
21336 box_out("found.");
21337 box_eol();
21338 catchup=false;
21339 }
21340
21341
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Misc. Data...");
21342
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readmisc(f, &tempheader, Misc);
21343
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21344
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21345
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21346 126 break;
21347
21348 case ID_TILES:
21349
21350 //tiles
21351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21352 {
21353 box_out("found.");
21354 box_eol();
21355 catchup=false;
21356 }
21357
21358
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Tiles...");
21359
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21360
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21361
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21362
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21363 126 break;
21364
21365 case ID_COMBOS:
21366
21367 //combos
21368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21369 {
21370 box_out("found.");
21371 box_eol();
21372 catchup=false;
21373 }
21374
21375
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Combos...");
21376
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21377 126 combosread=true;
21378
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21379
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21380
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21381 126 break;
21382
21383 case ID_COMBOALIASES:
21384
21385 //combo aliases
21386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
21387 {
21388 box_out("found.");
21389 box_eol();
21390 catchup=false;
21391 }
21392
21393
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading Combo Aliases...");
21394
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21395
1/9
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
21396
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
21397
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
21398 114 break;
21399
21400 case ID_CSETS:
21401
21402 //color data
21403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21404 {
21405 box_out("found.");
21406 box_eol();
21407 catchup=false;
21408 }
21409
21410
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Color Data...");
21411
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21412
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21413
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21414
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21415 126 break;
21416
21417 case ID_MAPS:
21418
21419 //maps
21420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21421 {
21422 box_out("found.");
21423 box_eol();
21424 catchup=false;
21425 }
21426
21427
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Maps...");
21428
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readmaps(f, &tempheader);
21429 126 mapsread=true;
21430
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21431
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21432
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21433 126 break;
21434
21435 case ID_DMAPS:
21436
21437 //dmaps
21438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21439 {
21440 box_out("found.");
21441 box_eol();
21442 catchup=false;
21443 }
21444
21445
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading DMaps...");
21446
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21447
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21448
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21449
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21450 126 break;
21451
21452 case ID_DOORS:
21453
21454 //door combo sets
21455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21456 {
21457 box_out("found.");
21458 box_eol();
21459 catchup=false;
21460 }
21461
21462
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Doors...");
21463
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readdoorcombosets(f, &tempheader);
21464
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21465
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21466
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21467 126 break;
21468
21469 case ID_ITEMS:
21470
21471 //items
21472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21473 {
21474 box_out("found.");
21475 box_eol();
21476 catchup=false;
21477 }
21478
21479
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Items...");
21480
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readitems(f, tempheader.zelda_version, tempheader.build);
21481
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21482
21483
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21484
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21485 126 break;
21486
21487 case ID_WEAPONS:
21488
21489 //weapons
21490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21491 {
21492 box_out("found.");
21493 box_eol();
21494 catchup=false;
21495 }
21496
21497
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Weapons...");
21498
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readweapons(f, &tempheader);
21499
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21500
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21501
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21502 126 break;
21503
21504 case ID_COLORS:
21505
21506 //misc. colors
21507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
21508 {
21509 box_out("found.");
21510 box_eol();
21511 catchup=false;
21512 }
21513
21514
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading Misc. Colors...");
21515
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readmisccolors(f, &tempheader, Misc);
21516
1/9
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
21517
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
21518
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
21519 114 break;
21520
21521 case ID_ICONS:
21522
21523 //game icons
21524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
21525 {
21526 box_out("found.");
21527 box_eol();
21528 catchup=false;
21529 }
21530
21531
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading Game Icons...");
21532
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readgameicons(f, &tempheader, Misc);
21533
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
21534
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
21535
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
21536 114 break;
21537
21538 case ID_INITDATA:
21539
21540 //initialization data
21541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21542 {
21543 box_out("found.");
21544 box_eol();
21545 catchup=false;
21546 }
21547
21548
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Init. Data...");
21549
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readinitdata(f, &tempheader);
21550
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21551
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21552
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21553
21554
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 if(!get_bit(skip_flags, skip_subscreens))
21555 {
21556
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 99 times.
126 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21557 {
21558
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 setupsubscreens();
21559
21560
2/2
✓ Branch 0 taken 13824 times.
✓ Branch 1 taken 27 times.
13851 for(int32_t i=0; i<MAXDMAPS; ++i)
21561 {
21562 13824 int32_t type=DMaps[i].type&dmfTYPE;
21563
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 13617 times.
13824 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21564
1/2
✓ Branch 0 taken 13824 times.
✗ Branch 1 not taken.
13824 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21565 13824 }
21566 27 }
21567 126 }
21568
21569
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 if(!get_bit(skip_flags, skip_sfx))
21570 {
21571 126 setupsfx();
21572 126 }
21573
21574
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!get_bit(skip_flags, skip_itemdropsets))
21575 {
21576
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 init_item_drop_sets();
21577 126 }
21578
21579
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!get_bit(skip_flags, skip_favorites))
21580 {
21581 126 init_favorites();
21582 126 }
21583
21584 126 break;
21585
21586 case ID_GUYS:
21587
21588 //guys
21589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21590 {
21591 box_out("found.");
21592 box_eol();
21593 catchup=false;
21594 }
21595
21596
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Custom Guy Data...");
21597
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readguys(f, &tempheader);
21598
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21599
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21600
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21601 126 break;
21602
21603 case ID_HEROSPRITES:
21604
21605 //player sprites
21606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
21607 {
21608 box_out("found.");
21609 box_eol();
21610 catchup=false;
21611 }
21612
21613
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading Custom Player Sprite Data...");
21614
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readherosprites(f, &tempheader);
21615
1/9
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
21616
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
21617
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
21618 114 break;
21619
21620 case ID_SUBSCREEN:
21621
21622 //custom subscreens
21623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
21624 {
21625 box_out("found.");
21626 box_eol();
21627 catchup=false;
21628 }
21629
21630
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading Custom Subscreen Data...");
21631
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readsubscreens(f);
21632
1/9
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
21633
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
21634
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
21635 114 break;
21636
21637 case ID_FFSCRIPT:
21638
21639 //Freeform combo scripts
21640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
21641 {
21642 box_out("found.");
21643 box_eol();
21644 catchup=false;
21645 }
21646
21647
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading FF Script Data...");
21648
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readffscript(f, &tempheader);
21649
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
21650
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
21651
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
21652 114 break;
21653
21654 case ID_SFX:
21655
21656 //SFX data
21657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
21658 {
21659 box_out("found.");
21660 box_eol();
21661 catchup=false;
21662 }
21663
21664
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading SFX Data...");
21665
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readsfx(f, &tempheader);
21666
1/9
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
21667
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
21668
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
21669 114 break;
21670
21671 case ID_MIDIS:
21672
21673 //midis
21674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21675 {
21676 box_out("found.");
21677 box_eol();
21678 catchup=false;
21679 }
21680
21681
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Tunes...");
21682
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readtunes(f, &tempheader, tunes);
21683
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21684
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21685
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21686 126 break;
21687
21688 case ID_CHEATS:
21689
21690 //cheat codes
21691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21692 {
21693 box_out("found.");
21694 box_eol();
21695 catchup=false;
21696 }
21697
21698
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Cheat Codes...");
21699
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readcheatcodes(f, &tempheader);
21700
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21701
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21702
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21703 126 break;
21704
21705 case ID_ITEMDROPSETS:
21706
21707 //item drop sets
21708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
21709 {
21710 box_out("found.");
21711 box_eol();
21712 catchup=false;
21713 }
21714
21715
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading Item Drop Sets...");
21716
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build);
21717
1/9
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
21718
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
21719
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
21720 114 break;
21721
21722 case ID_FAVORITES:
21723
21724 //favorite combos and combo aliases
21725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
21726 {
21727 box_out("found.");
21728 box_eol();
21729 catchup=false;
21730 }
21731
21732
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading Favorite Combos...");
21733
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readfavorites(f, tempheader.zelda_version, tempheader.build);
21734
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
21735
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
21736
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
21737 114 break;
21738
21739 default:
21740 if(!catchup)
21741 {
21742 box_out("Bad token! Searching...");
21743 box_eol();
21744 }
21745
21746 catchup=true;
21747 break;
21748 }
21749
21750
21751
1/2
✓ Branch 0 taken 2916 times.
✗ Branch 1 not taken.
2916 if(catchup)
21752 {
21753 //section id
21754 section_id=(section_id<<8);
21755
21756 if(!p_getc(&tempbyte,f))
21757 {
21758 return qe_invalid;
21759 }
21760
21761 section_id+=tempbyte;
21762 }
21763
21764 else
21765 {
21766 //section id
21767
3/4
✓ Branch 0 taken 2916 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2790 times.
✓ Branch 3 taken 126 times.
2916 if(!pack_feof(f))
21768 {
21769
2/4
✓ Branch 0 taken 2790 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2790 times.
✗ Branch 3 not taken.
2790 if(!p_mgetl(&section_id,f))
21770 {
21771 return qe_invalid;
21772 }
21773 2790 }
21774 }
21775 }
21776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 }
21777 else
21778 {
21779
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
21780
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
21781
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
21782
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
21783
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
21784
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
21785
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
21786
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
21787
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
21788
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
21789
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
21790
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
21791
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
21792
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
21793
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
21794
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
21795
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Player Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1, 0); }},
21796
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1, 0); }},
21797 };
21798
21799
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 68 times.
140 for (auto& [desc, section_id, fn] : hardcoded_sections)
21800 {
21801 // Would be nice, but old sections mostly did not save section sizes. We could advance by
21802 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
21803 // read all the sections even if requested to skip some.
21804 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21805 // {
21806 // if (retval == qe_cancel)
21807 // continue;
21808 // checkstatus(retval);
21809 // }
21810
21811
3/6
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 68 times.
✗ Branch 5 not taken.
136 box_out(fmt::format("Reading {}...", desc).c_str());
21812
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 ret = fn();
21813
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
68 checkstatus(ret);
21814
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_out("okay.");
21815
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_eol();
21816 }
21817
21818
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!get_bit(skip_flags, skip_subscreens))
21819 {
21820
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 setupsubscreens();
21821
21822
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t i=0; i<MAXDMAPS; ++i)
21823 {
21824 2048 int32_t type=DMaps[i].type&dmfTYPE;
21825
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2036 times.
2048 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21826
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21827 2048 }
21828 4 }
21829
21830
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("Setting Up Default Sound Effects...");
21831
21832
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(!get_bit(skip_flags, skip_sfx))
21833 4 setupsfx();
21834
21835
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(!get_bit(skip_flags, skip_favorites))
21836 4 init_favorites();
21837
21838
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("okay.");
21839
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_eol();
21840
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 }
21841
21842 130 init_spritelists();
21843
21844 // check data
21845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(f)
21846 {
21847 130 pack_fclose(f);
21848 130 }
21849 130 clear_quest_tmpfile();
21850
21851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(!oldquest)
21852 {
21853
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(exists(tmpfilename))
21854 {
21855 delete_file(tmpfilename);
21856 }
21857 130 }
21858
21859
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if(fixffcs && combosread && mapsread)
21860 {
21861 for(int32_t i=0; i<map_count; i++)
21862 {
21863 for(int32_t j=0; j<MAPSCRS; j++)
21864 {
21865 for(int32_t m=0; m<32; m++)
21866 {
21867 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
21868 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
21869 }
21870 }
21871 }
21872 }
21873
21874
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 29 times.
130 if(get_qr(qr_CONTFULL_DEP))
21875 {
21876 29 set_qr(qr_CONTFULL_DEP, 0);
21877 29 set_bit(zinit.misc, idM_CONTPERCENT, 1);
21878 29 zinit.cont_heart=100;
21879 29 zinit.start_heart=zinit.hc;
21880 29 }
21881
21882 130 box_out("Done.");
21883 130 box_eol();
21884 130 box_end(false);
21885
21886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(!get_bit(skip_flags, skip_header))
21887 {
21888 130 memcpy(Header, &tempheader, sizeof(tempheader));
21889 130 }
21890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(!get_bit(skip_flags, skip_zinfo))
21891 {
21892 130 ZI.copyFrom(tempzi);
21893 130 }
21894
21895
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(get_bit(skip_flags, skip_maps))
21896 {
21897 map_count=old_map_count;
21898 }
21899
21900
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(get_bit(skip_flags, skip_rules))
21901 {
21902 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
21903 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
21904 }
21905
21906
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(get_bit(skip_flags, skip_midis))
21907 {
21908 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
21909 }
21910
21911 //Debug FFCore.quest_format[]
21912 130 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
21913 130 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
21914 130 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
21915 130 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
21916 130 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
21917 130 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
21918 130 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
21919 130 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
21920 130 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
21921 130 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
21922 130 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
21923 130 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
21924 130 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
21925 130 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
21926 130 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
21927 130 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
21928 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
21929 130 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
21930 130 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
21931 130 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
21932 130 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
21933 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
21934 130 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
21935 130 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
21936 130 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
21937 130 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
21938 130 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
21939 130 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
21940 130 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
21941 130 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
21942 //Print metadata for versions under 2.10 here. Bleah.
21943
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if( FFCore.quest_format[vZelda] < 0x210 )
21944 {
21945 4 zprint2("\n[ZQUEST CREATOR METADATA]\n");
21946
21947
1/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
4 switch(FFCore.quest_format[vZelda])
21948 {
21949 case 0x193:
21950 {
21951 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
21952 }
21953 case 0x192:
21954 {
21955 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
21956 }
21957 case 0x190:
21958 {
21959 4 zprint2("Last saved in ZC Editor Version: 1.90");
21960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
21961 4 else zprint2("\n");
21962 4 break;
21963 }
21964 case 0x188:
21965 {
21966 zprint2("Last saved in ZC Editor Version: 1.88");
21967 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
21968 else zprint2("\n");
21969 break;
21970 }
21971 case 0x187:
21972 {
21973 zprint2("Last saved in ZC Editor Version: 1.87");
21974 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
21975 else zprint2("\n");
21976 break;
21977 }
21978 case 0x186:
21979 {
21980 zprint2("Last saved in ZC Editor Version: 1.86");
21981 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
21982 else zprint2("\n");
21983 break;
21984 }
21985 case 0x185:
21986 {
21987 zprint2("Last saved in ZC Editor Version: 1.85");
21988 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
21989 else zprint2("\n");
21990 break;
21991 }
21992 case 0x184:
21993 {
21994 zprint2("Last saved in ZC Editor Version: 1.84");
21995 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
21996 else zprint2("\n");
21997 break;
21998 }
21999 case 0x183:
22000 {
22001 zprint2("Last saved in ZC Editor Version: 1.83");
22002 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22003 else zprint2("\n");
22004 break;
22005 }
22006 case 0x182:
22007 {
22008 zprint2("Last saved in ZC Editor Version: 1.82");
22009 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22010 else zprint2("\n");
22011 break;
22012 }
22013 case 0x181:
22014 {
22015 zprint2("Last saved in ZC Editor Version: 1.81");
22016 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22017 else zprint2("\n");
22018 break;
22019 }
22020 case 0x180:
22021 {
22022 zprint2("Last saved in ZC Editor Version: 1.80");
22023 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22024 else zprint2("\n");
22025 break;
22026 }
22027 default:
22028 {
22029 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22030 }
22031 }
22032 4 }
22033
22034 130 return qe_OK;
22035
22036 invalid:
22037 box_out("error.");
22038 box_eol();
22039 box_end(true);
22040
22041 if(f)
22042 {
22043 pack_fclose(f);
22044 }
22045
22046 if(!oldquest)
22047 {
22048 if(exists(tmpfilename))
22049 {
22050 delete_file(tmpfilename);
22051 }
22052 }
22053
22054 return qe_invalid;
22055
22056 130 }
22057
22058 130 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22059 {
22060 130 const char* basename = get_filename(filename);
22061 130 zapp_reporting_add_breadcrumb("load_quest", basename);
22062 130 zapp_reporting_set_tag("qst.filename", basename);
22063
22064 130 loading_qst_name = filename;
22065 130 loading_qst_num = qst_num;
22066 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22067 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22068
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if (!is_ci())
22069 loadquest_report = report;
22070 130 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22071 130 load_tmp_zi = NULL;
22072 130 loading_qst_name = NULL;
22073 130 loadquest_report = false;
22074 130 loading_qst_num = 0;
22075
22076 130 zapp_reporting_set_tag("qst.title", Header->title);
22077 130 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22078
22079 130 return ret;
22080 }
22081